Generate Circular Student Arrangements
Updated
Problem statement
The distinct identifiers in students must be seated around a circle. Two arrangements are considered the same if one can be rotated to obtain the other. Reflections are different because clockwise neighbor order changes.
Return every distinct circular arrangement. Serialize one arrangement by starting with the lexicographically smallest student and joining the clockwise identifiers with >. Return the serialized arrangements in lexicographic order.
Function
circularStudentArrangements(students: String[]) → String[]Examples
Example 1
students = ["Ada","Ben","Cam"]return = ["Ada>Ben>Cam","Ada>Cam>Ben"]Fixing Ada first leaves the clockwise orders Ben-Cam and Cam-Ben.
Example 2
students = ["Zoe","Amy"]return = ["Amy>Zoe"]After rotations are merged, two students have one circular arrangement.
Example 3
students = ["d","b","a","c"]return = ["a>b>c>d","a>b>d>c","a>c>b>d","a>c>d>b","a>d>b>c","a>d>c>b"]Anchoring a and permuting the other three students produces six results.
Constraints
1 <= students.length <= 8.- Identifiers are distinct nonempty alphanumeric strings of length at most
12. - Identifiers do not contain
>.
More Amazon Onsite Interview questions
- Number of IslandsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Cheapest Flights Within K StopsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Dungeon GameONSITE INTERVIEW · Seen Nov 2026
- Integer BreakONSITE INTERVIEW · Seen Nov 2026
- LFU CacheONSITE INTERVIEW · Seen Nov 2026
- LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Count Adjacent Symbol Pairs for BPEONSITE INTERVIEW · Seen Nov 2026
- First Non-Repeating CharacterOA · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Partition into Equal-Sum GroupsPalo Alto Networks · ONSITE INTERVIEWPalo Alto Networks interview questions
- Bounded Combination Sum with Signed CandidatesConfluent · ONSITE INTERVIEWConfluent interview questions
- Count Triplets With Sum at Most TargetGoogle · ONSITE INTERVIEWGoogle interview questions
- Reduce Array Size to At Most HalfMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Enumerate Character Paths to a MarkerTesla · ONSITE INTERVIEWTesla interview questions
- Subsets IIBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
- Inventory Outfit CombinationsRoblox · ONSITE INTERVIEWRoblox interview questions
- Enumerate Compatible Meeting SubsetsExpedia · ONSITE INTERVIEWExpedia interview questions
- PermutationsEPAM · PHONE SCREENEPAM interview questions
- Permutations IILinkedIn · PHONE SCREENLinkedIn interview questions