Leetcode 1040. Moving Stones Until Consecutive II
Given integer positions of stones, determine the minimum and maximum number of moves (each move relocates an endpoint stone to a non-endpoint spot) required to make all stones occupy consecutive integer positions. After sorting, the task reduces to sliding-window and gap analysis — min moves by packing the largest subset into a length-(n-1) interval (with one small special-case), and max moves driven by the largest outer gap.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.