Problem 3532 · Medium

Path Existence Queries in a Graph I

Sorted values only connect to their neighbours, so the connected pieces are runs of consecutive values with small gaps; label each run and compare labels.

Open the interactive visualisation