#796
Rotate String
pupil · 335 · lc easy +22 · verified · 65.2% accepted · 4,819 likes · top 69%
Description
Given two strings s and goal, return true if and only if s can be transformed into goal by performing some number of left-shift operations on s.
A left-shift moves the leftmost character of s to its rightmost position.
- For example, applying one left-shift to s = "abcde" produces "bcdea".
Example 1:
Input: s = "abcde", goal = "cdeab"
Output: true
Example 2:
Input: s = "abcde", goal = "abced"
Output: false
Code
1
2
3