Unique DNA Sequences Under Circular Rotation
Problem statement
Given DNA strings made of A, C, G, and T, count the distinct sequences when two strings are considered equal if one is a circular rotation of the other.
Function
countUniqueRotations(sequences: String[]) → intExamples
Example 1
sequences = ["TGAAA","ATGAA","AATGA"]return = 1All three strings belong to one rotation class.
Example 2
sequences = ["AAA","TAA","TAT","ATA"]return = 3TAA, AAT, and ATA are rotations; AAA and TAT each form another class.
Constraints
1 <= sequences.length <= 1000.- All strings are non-empty, have the same length, and contain only
A,C,G, andT. - Each string length is at most
200.