Rotated Arrays

Given two arrays of integers A and B, of same size, check and return whether B is rotated form of A or not.
Both left and right rotations are possible.



Input Format

The first argument given is the integer array A.
The second argument given is the integer array B.

Output Format

Return 1 if B is rotated form of A else return 0.

Constraints

1 <= length of both arrays <= 100000
-10^9 <= A[i], B[i] <= 10^9 

For Example

Input 1:
    A = [1, 2, 3, 4, 5]
    B = [3, 4, 5, 1, 2]
Output 1:
    1

Input 2:
    A = [5, 17, 100, 11]
    B = [5, 100, 17, 11]
Output 2:
    0
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Rotated Arrays on Interview Code Editor
Hints
  • Hints are not available for this problem

Discussion


Loading...
Click here to start solving coding interview questions