Leetcode Problem 796. Rotate String

796. Rotate String

Leetcode Solutions

Approach #: Simple Check

  1. Check if the lengths of s and goal are equal. If not, return false.
  2. Concatenate s with itself to create a new string s+s.
  3. Check if goal is a substring of s+s.
  4. If goal is a substring of s+s, return true. Otherwise, return false.
UML Thumbnail

Approach #: Brute Force

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...