Skip to content

Practice Moving Stones Until Consecutive

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1033
LeetCode Problem

Moving Stones Until Consecutive

Problem Statement

Three stones occupy distinct integer positions a, b and c. In a move, choose the leftmost or rightmost stone and place it at any unoccupied integer position strictly between the current endpoints. Play ends when the three stones occupy consecutive positions. Return [minimumMoves, maximumMoves], the smallest and largest possible numbers of moves before the game ends.

Source: Moving Stones Until Consecutive on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
a = 1, b = 2, c = 5
Output
[1,2]

# Example 2

Input
a = 4, b = 3, c = 2
Output
[0,0]

# Example 3

Input
a = 3, b = 5, c = 1
Output
[1,2]

Constraints

1 <= a, b, c <= 100
a, b, and c have different values.

Related LeetCode Problems

Practice more problems similar to Moving Stones Until Consecutive.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.