GamifiedGamified challengesPracticeRaceLeaderboardPricing

Learn data structures by watching them move, then doing it yourself. Press M anytime to toggle sound.

A product of Amypo Technologies, Coimbatore.

Learn

  • All topics
  • Learning path
  • How it works
  • About dotprep

Practice

  • Practice arena
  • Daily challenge
  • Gamified challenges
  • Race mode
  • Leaderboard

Interview prep

  • Java interview
  • Coding questions
  • Company questions
  • System design
  • Jobs & careers

You

  • Dashboard
  • Settings
  • Pricing
  • Create account

© 2026 dotprep

Content last updated 20 November 2026

GamifiedGamified challengesPracticeRaceLeaderboardPricing
Log inStart free
Gamified challengesMountain Peak Finder

Gamified challenge · Binary search on the slope

Mountain Peak Finder

heights[i] is the ridge's height at point i, and no two neighbours are equal. A peak is a point taller than each of its neighbours; beyond both ends the ground drops away forever, so the first or last point can be a peak too.

Write peak(heights) that returns the index of any peak. Several peaks may exist; every one of them is accepted. Try to check only about log2 n heights instead of walking the whole ridge.

Example: for [1, 2, 1, 3, 5, 6, 4] both 1 (height 2) and 5 (height 6) are right; for [1, 2, 3, 1] the only peak is 2.

Sign in to play Mountain Peak Finder

This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.

Sign in with Google

or log in with email · create an account