All problems
0215MediumArrayBinary SearchTernary Search

Kiln Ramp Peak

Tracked in this browser only
Write code

Trains the technique from

LeetCode 852Peak Index in a Mountain Array

This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.

Same function shape, different story and different numbers.

A pottery kiln writes down its chamber temperature once a minute for one firing cycle. The log is a single ramp: reading by reading the temperature climbs to one hottest minute, and from that minute onward it drops, reading by reading, until the cycle ends. No two neighbouring readings are ever equal, the climb is at least one minute long, and so is the drop, so the hottest minute is never the first or last entry.

You are given the log as readings. Return the position of the hottest reading, counting positions from 0.

Your routine must run in time logarithmic in the length of readings.

Examples

Example 1

Input
readings = [120, 480, 910, 300]
Output
2

Position 2 holds 910. The readings before it climb, 120 then 480, and the reading after it, 300, is lower.

Example 2

Input
readings = [15, 62, 41, 33, 9]
Output
1

Position 1 holds 62, above the 15 that precedes it, and every later reading is below the one before it.

Example 3

Input
readings = [0, 4, 7, 12, 300, 299]
Output
4

The climb runs through positions 0 to 4 and the only drop is the final 299, so the hottest minute sits at position 4.

Constraints

  • 3 <= readings.length <= 10^5
  • 0 <= readings[i] <= 10^6
  • readings climbs strictly to one hottest entry and then drops strictly
  • the hottest entry is neither the first nor the last entry

The signature

The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

Python
def kiln_ramp_peak(readings: list[int]) -> int:
Java
public int kilnRampPeak(int[] readings)
September 7
Apply