For each element, scan the array (wrapping around) to find the first greater element.
Each element might scan almost the entire array. With elements, that's time.
Can you simulate the circular traversal efficiently?
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
The trap
For each element, scan the array (wrapping around) to find the first greater element.
Each element might scan almost the entire array. With elements, that's time.
Can you simulate the circular traversal efficiently?