The TransCompilator

Solved LeetCode program · 374 of 1,000

#0503 · Next Greater Element II

Medium Array chunk-08.md

Original English source

Keep a shared numbers holding 1, 2, and 1. Keep a shared width of 0. Keep a shared answer of 0. Keep a shared last of 2. Set width to last plus 1.

To seek from step (a whole number) with spot (a whole number). If step is at least width, set answer to -1, return. The other is spot plus step. If other is more than last, set other to other minus width. If item other of numbers is more than item spot of numbers, set answer to item other of numbers, return. Seek from step plus 1 with spot.

For every spot from 0 to last.
Set answer to -1. Seek from 1 with spot. Show answer.

Open in Playground Browse all 1,000 problems

Expected stdout

2
-1
2