Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
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.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.