Find Peak Element

Medium Binary Search AI round

How it works

  1. Press Start. 30:00 on the clock, and it keeps running if you leave the page.
  2. Use an AI agent. 20 messages, anything about the problem. It can write code, but how you use it is scored.
  3. Run your code on the examples and your own cases, up to 20 runs in 10 minutes.
  4. Submit to run the hidden tests and end the round.

What the report looks at Example figures

  • SolutionOptimal · O(n)
  • Hidden tests12 of 12
  • AI agent use78 / 100
  • Cost$0.004
  • Time14:32 of 30:00

The problem

nums is a list of whole numbers in which no two numbers next to each other are equal.

A peak is a position whose number is larger than the numbers on either side of it. Beyond both ends of the list, count the outside as lower than every number: the first position need only beat the second, the last only the one before it, and a list of one number has its peak at position 0.

Return the position of a peak, counting from 0. Every such list has at least one, and when it has several, any of them is right.

Read the full problem

Solve it without the AI agent

Write it in Python, Java or C++, run it on your own cases, and submit against hidden tests.

Open the practice page

More Binary Search

All Binary Search problems