796. Rotate String
/**
* 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);
}
}
"""
Problem: LeetCode 796 - Rotate String
Difficulty: Easy
Language: Python
Author: CodeByTushu
"""
class Solution:
def rotateString(self, s: str, goal: str) -> bool:
return len(s) == len(goal) and goal in (s + s)
/**
* Problem: LeetCode 796 - Rotate String
* Difficulty: Easy
* Language: C++
* Author: CodeByTushu
*/
#include <string>
using namespace std;
/**
* Problem: LeetCode 796 - Rotate String
* Difficulty: Easy
* Language: C++
* Author: CodeByTushu
*/
class Solution {
public:
bool rotateString(string s, string goal) {
return s.length() == goal.length() && (s + s).find(goal) != string::npos;
}
};
/**
* Problem: LeetCode 796 - Rotate String
* Difficulty: Easy
* Language: JavaScript
* Author: CodeByTushu
*/
var rotateString = function(s, goal) {
return s.length === goal.length && (s + s).includes(goal);
};