796. Rotate String ¶ Time: $O(|\texttt{s}|^2)$ Space: $O(1)$ C++JavaPython 1 2 3 4 5 6class Solution { public: bool rotateString(string s, string goal) { return s.length() == goal.length() && (s + s).find(goal) != string::npos; } }; 1 2 3 4 5class Solution { public boolean rotateString(String s, String goal) { return s.length() == goal.length() && (s + s).contains(goal); } } 1 2 3class Solution: def rotateString(self, s: str, goal: str) -> bool: return len(s) == len(goal) and goal in s + s