Created
November 13, 2018 16:04
-
-
Save runandrerun/9ad8a2bb1d93687595b4e9b699518ea9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Input: Initial State = [2, 3, 4, 5] | Unlock Code = [5, 4, 3, 2] | |
Output: Rotations required = 8 | |
Explanation : 1st ring is rotated 3 times as 2 => 3 => 4 => 5 | |
2nd ring is rotated 1 time as 3 => 4 | |
3rd ring is rotated 1 time as 4 => 3 | |
4th ring is rotated 3 times as 5 => 4 => 3 =>2 | |
Input: Initial State = [1, 9, 1, 9] | Unlock Code = [0, 0, 0, 0] | |
Output: Rotations Required = 4 | |
Explanation : 1st ring is rotated 1 time as as 1 => 0 | |
2nd ring is rotated 1 time as 9 => 0 | |
3rd ring is rotated 1 time as 1 => 0 | |
4th ring is rotated 1 time as 9 => 0 | |
Input: Initial State = [0, 0, 0] | Unlock Code = [3, 1, 8] | |
Output: Rotations Required = 6 | |
Explanation: 1st ring is rotated 3 times as 0 => 1 => 2 => 3 | |
2nd ring is rotated 1 time as 0 => 1 | |
3rd ring is rotated 2 times as 0 => 9 => 8 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment