Moving Stones Until Consecutive II - Python Solution @ LeetCode
Moving Stones Until Consecutive II, is a LeetCode problem. In this post we will see how we can solve this challenge in Python
Problem Description
Each turn, you pick up an endpoint stone and move it to an unoccupied position so that it is no longer an endpoint stone.
The game ends when you cannot make any more moves, ie. the stones are in consecutive positions.
Example 1:
Input: [7,4,9] Output: [1,2] Explanation: We can move 4 -> 8 for one move to finish the game. Or, we can move 9 -> 5, 4 -> 6 for two moves to finish th ....
You can find the full details of the problem Moving Stones Until Consecutive II at LeetCode
Solution: Please check the main.py snippet for the solution.
This solution originally posted at: Github by @kamyu104
Comments
Leave a comment
You are not LoggedIn but you can comment as an anonymous user which requires manual approval. For better experience please Login .