LeetCode içerisinde bulunan “Rotate String” sorusunun açıklaması ve çözümü. Bu soruda sizi verilen iki string‘ten, ilk string herhangi bir sayıda rotasyon ile ikinci string’e dönüşüp dönüşemeyeceği soruluyor.
► LeetCode 796. Rotate String: https://leetcode.com/problems/rotate-string/
► Problem açıklaması:
We are given two strings, s and goal.
A shift on s consists of taking string s and moving the leftmost character to the rightmost position. For example, if s = ‘abcde’, then it will be ‘bcdea’ after one shift on s. Return true if and only if s can become goal after some number of shifts on s.
Example 1:
Input: s = ‘abcde’, goal = ‘cdeab’
Output: true
Example 2:
Input: s = ‘abcde’, goal = ‘abced’
Output: false
Note:
s and goal will have length at most 100.