Opening your workspace…
Workspace/Coding room
Opening your workspace…
A sensor records the temperature of consecutive batches. For each batch, find the first later batch with a strictly lower temperature, considering only the next horizon positions. Return an array of distances to those batches. A distance of 1 means the immediately following batch. Return 0 for a batch if no strictly cooler batch occurs within the horizon. Equal temperatures do not count as cooler.
[9,7,8,5], 2OUTPUT[1,2,1,0]For temperature 7 at index 1, the cooler 5 is two positions away. The other two nonfinal batches have a cooler immediate neighbor.
[4,4,3], 1OUTPUT[0,1,0]The equal 4 does not help index 0, and 3 is outside its one-position horizon. Index 1 can reach 3.
Tab inserts two spaces. Press Escape, then Tab, to leave the editor. Press Control or Command and Enter to submit.
[9,7,8,5], 2[1,2,1,0]Public samples only. These checks do not award ranked points.
Walk through a solution, check its time and space costs, and compare it with yours.
Checking your progress…