FastPrepGroup Rotation-Equivalent Strings
Problems/Group Rotation-Equivalent Strings

Group Rotation-Equivalent Strings

Google logoGoogle● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The Google DS/MLE phone screen asks to group rotation-equivalent strings and gives abc, bca, cab and xyz. Output order, duplicate/empty behavior, character domain and size limits are practice assumptions. Approximate source match: 90%.

Given a list of strings, group strings that can be converted into each other by rotating characters. A rotation moves any prefix to the end, preserving the character order.

For this exercise, assume strings contain lowercase ASCII letters and may be empty. Return all groups in the order their first member appears in the input. Within each group, keep the original input order and retain duplicate entries. Empty strings are rotation-equivalent to each other. Rotation never changes string length; anagrams with a different cyclic order belong to different groups.

Function

groupRotations(words: String[]) → String[][]

Examples

Example 1

words = ["abc","bca","cab","xyz"]return = [["abc","bca","cab"],["xyz"]]

abc, bca and cab form one group; xyz forms a separate group.

Example 2

words = ["xyz","cab","zxy","abc","bca"]return = [["xyz","zxy"],["cab","abc","bca"]]

The xyz group appears first because its first member occurs first. Every group keeps input member order.

Example 3

words = ["","","a","a","aa"]return = [["",""],["a","a"],["aa"]]

Empty strings and repeated entries are preserved; a and aa are not rotations of each other.

Constraints

  • For this exercise, assume 0 <= words.length <= 200.
  • Each string has at most 100 lowercase ASCII letters.
  • The sum of string lengths is at most 2000.

More Google Phone Screen questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Classify Password StrengthHackerRank · OA · PHONE SCREEN · ONSITE INTERVIEWHackerRank interview questions
  • Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Dasher Pay with Store Waits and Peak HoursDoorDash · PHONE SCREENDoorDash interview questions
  • Fuzzy Word Lookup With One Misspelled LetterMeta · PHONE SCREENMeta interview questions
  • Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Group Timestamps into Consecutive-Day IntervalsDuolingo · PHONE SCREENDuolingo interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Longest Substring Without Repeating CharactersAngel One · PHONE SCREEN
  • Group AnagramsWorkday · PHONE SCREEN

Interview reports that mention this question

  • Google SWE III ML Experienced Loops: 10 Experiences (Part 3 of 4)

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public String[][] groupRotations(String[] words) {
        // Write your code here
    }
}
Checking account…