Unofficial C Solution to Problem 1.8 in Cracking the Coding Interview (5th Edition) | Code Says
If string str1 is a rotation of string str2, it must holds two conditions:
- The length of str1 equals to the length of str2;
- There is at least a set of two string A and B, such that str1=AB and str2=BA. We double str1, and get a new string as ABAB. If str2 is a rotation of str1, str2 must be a substring of this new string.
Read full article from Unofficial C Solution to Problem 1.8 in Cracking the Coding Interview (5th Edition) | Code Says
No comments:
Post a Comment