← All problemsSign in

Up Down

A Frog present at the bottom of the well of height $H$, needs to get out of it, using the slippery wall of the well. It decides to climb up the well, it goes up $U$ metres and slips down $D$ metres in one single step. So, in each step it covers $(U-D)$ metres, and if the spider gets out of the well by covering $U$ metres in the last step it doesn't slips back. For example, if the spider climbs up

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start