Back to May Back to Year 2026
EASY 03 May 2026 View on LeetCode

796. Rotate String

</> Solution

/**
 * Problem: LeetCode 796 - Rotate String
 * Difficulty: Easy
 * Language: Java
 * Author: CodeByTushu
 */
class Solution {
    public boolean rotateString(String s, String goal) {
        return s.length() == goal.length() && (s + s).contains(goal);
    }
}

TIME COMPLEXITY

O(N)

SPACE COMPLEXITY

O(N)

TOPICS

String String Matching