FastPrepGenerate Circular Student Arrangements
Problems/Generate Circular Student Arrangements

Generate Circular Student Arrangements

Amazon logoAmazon● MediumNEW GRADONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: Amazon Experience 24 asks candidates to generate every student ordering and then changes the queue into a circle. The source does not define rotational equivalence or output order. This practice contract removes rotational duplicates by anchoring the lexicographically smallest student, treats reflections as different clockwise orders, and returns lexicographic output. Core-task fidelity is about 88%.

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 problems

  • Number of IslandsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Minimum Cost of Left and Right PropagationOA · Seen Nov 2026
  • 3SumPHONE SCREEN · Seen Nov 2026
See Amazon hiring insights
Saved
class Solution {
    public String[] circularStudentArrangements(String[] students) {
      // write your code here
    }
}
Checking account…