dsa5 min read
Rotate String — The Concatenation Trick [LC 796]
LeetCode 796 — asked at Amazon and Google. Check if string s can become string goal by rotating. The elegant O(n) trick: concatenate s with itself and check if goal is a substring. One line of code once you see the insight.
Read →