← All problemsSign in

Mountains

There are $N$ mountains, each having a height $H_i$ $(1\leq i\leq N)$. Bob is standing on the first mountain. He wishes to move to the $N^{th}$ mountain. Bob can move from the $i^{th}$ mountain to the $j^{th}$ mountain if and only if $|H_i-H_j|\leq K$, where $K$ is an integer. Your task is to determine if he can reach the $N^{th}$ mountain. NOTE: the distance between the mountains doesn't ma

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