FastPrepUnique DNA Sequences Under Circular Rotation

Unique DNA Sequences Under Circular Rotation

Benchling logoBenchling● MediumFULLTIMEOA
Learn

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[]) → int

Examples

Example 1

sequences = ["TGAAA","ATGAA","AATGA"]return = 1

All three strings belong to one rotation class.

Example 2

sequences = ["AAA","TAA","TAT","ATA"]return = 3

TAA, 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, and T.
  • Each string length is at most 200.

More Benchling problems

See Benchling hiring insights
public int countUniqueRotations(String[] sequences) {
    // Write your code here.
}
sequences["TGAAA","ATGAA","AATGA"]
expected1
Checking account…