Like alwasy, feel free to check out source images for original problem statement. Thank U for your understanding~~~~~~
Examples
01 · Example 1
a = [13, 5604, 31, 2, 13, 4560, 546, 654, 456] return = 5
There are 5 cyclic pairs of numbers - pairs which are equal to each other after cyclic shifts.
- a[0] = 13 and a[4] = 13 (i = 0 and j = 4)
- a[0] = 13 and a[4] = 13 (i = 0 and j = 4)
- a[1] = 5604 and a[5] = 4560 (i = 1 and j = 5)
- a[2] = 31 and a[4] = 13 (i = 2 and j = 4)
- a[6] = 546 and a[7] = 654 (i = 6 and j = 7)
Note that a[6] = 546 and a[8] = 456 are not cyclic pairs - 546 can only be paired with cyclic shift of 546, 465 and 654.
Also, note that a[5] = 4560 and a[8] = 456 are not cyclic pairs because they have different number of digits.
More Roblox problems
- Candy Crush Grid Matching and GravityPHONE SCREEN · Seen Jun 2026
- Closest Binary Search Tree Value VariantPHONE SCREEN · Seen Jun 2026
- Design Search Autocomplete SystemPHONE SCREEN · Seen Jun 2026
- Find the Closest PalindromePHONE SCREEN · Seen Jun 2026
- Grid Pathfinding with Obstacles (DFS)PHONE SCREEN · Seen Jun 2026
- Maximize Distance to Closest PersonPHONE SCREEN · Seen Jun 2026
- Maximum Number of Balls in a BoxPHONE SCREEN · Seen Jun 2026
- Meeting Rooms IIPHONE SCREEN · Seen Jun 2026
public int shifOops(int[] a) {
// write your code here
}
a[13, 5604, 31, 2, 13, 4560, 546, 654, 456]
expected5
sign in to submit