Each string in bracelets lists the beads of a closed bracelet, read clockwise from some bead.
Because the bracelet is a loop, you may start reading at any bead, and because it can be
turned over, you may also read it anticlockwise. Two strings describe the same design if
one can be read from the other in one of these ways (so "abc", "bca" and "acb" are all the
same bracelet). Return the number of different designs in the list.
Examples
Input: bracelets = ["abcd", "cdab", "dcba", "abdc", "aab"]
Output: 3
Explanation: "abcd", "cdab" (start at c) and "dcba" (read backwards) are one design;
"abdc" is a different arrangement and "aab" is a third design.
Input: bracelets = ["ab", "ba", "aba"]
Output: 2
Constraints
0 <= len(bracelets) <= 2 * 10**41 <= len(bracelets[i]) <= 12, lowercase letters.- Target complexity: O(n * L^2) time, where L is the bracelet length.
Goals
- Pick one fixed representative for all rotations and flips of a string
- Store representatives in a set to count distinct designs
- Handle designs whose rotations repeat