129k views
3 votes
A string s is a circular shift of a string t if it matches when the the characters are circularly shifted by any number of positions. For example, ACTGACG is a circular shift of TGACGAC, and vice versa. Detecting this condition is important in the study of genomic sequences. Write a program that checks whether two given strings s and t are circular shifts of one another.

Hint: The solution is a one-liner with indexOf() and string concatenation.

User Jobi
by
4.7k points

1 Answer

6 votes
The solution
Nsmksmesmnwkwkwkkw
User Cory Quammen
by
4.6k points