BackmediumArrays Razorpay

Galactic Vessel Alignment Solution

Problem Statement

Given two sequences of celestial body identifications, determine if they can be made identical by rotating one of the sequences. If possible, find the minimum number of rotations required to make them identical.

Example 1
Input
[1, 2, 3, 4, 5, 0], [1, 2, 3, 4, 0]
Output
1

Explanation: Step-by-step: Given two sequences [1, 2, 3, 4, 5, 0] and [1, 2, 3, 4, 0], we can rotate the second sequence by one position to the right to make it identical to the first sequence. Therefore, the minimum number of rotations required is 1.

Example 2
Input
[1, 1, 2, 2, 3, 3], [1, 2, 3, 2, 1, 3]
Output
2

Explanation: Step-by-step: Given two sequences [1, 1, 2, 2, 3, 3] and [1, 2, 3, 2, 1, 3], we can rotate the second sequence by two positions to the right to make it identical to the first sequence. Therefore, the minimum number of rotations required is 2.

Constraints

  • The sequences will have a length between 2 and 100 elements.
  • All elements in the sequences are integers between 1 and 1000.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free