cracking-the-coding-interview icon indicating copy to clipboard operation
cracking-the-coding-interview copied to clipboard

Incorrect code in string rotation

Open alexrud-perf opened this issue 1 year ago • 0 comments

https://github.com/Turingfly/cracking-the-coding-interview/blob/efe6d6c5d7d57e64ec876d648e15cf79f98a014f/src/chapter01ArraysAndStrings/StringRotation.java#L15

current implementation always returns true, even if s2 contains all different characters: isRotation("abcd", "1234") -> true

it should be:

return isSubstring((s1 + s1), s2);

alexrud-perf avatar Nov 06 '24 16:11 alexrud-perf