Problem 1649 · Hard

Create Sorted Array through Instructions

Each inserted value costs the smaller of the count below it and the count above it; counting these is a sweep over the values seen so far.

Open the interactive visualisation