Rotation Check
A string rotation moves a piece from the beginning to the end without changing the order inside the pieces. The function is_rotated receives two strings, s1 and s2. Check whether s2 can be made from s1 by such a rotation. If the strings are already equal without any shift, that also counts as a valid rotation.
Примеры
Ввод
["hello", "hello"]Вывод
TrueВвод
["hello", "llohe"]Вывод
TrueВвод
["hello", "helol"]Вывод
FalseНужно реализовать
def is_rotated(s1: str, s2: str) -> bool:
Теги
strings
Connectez-vous pour voir l'historique des soumissions
Se connecterConnectez-vous pour utiliser le Mentor IA
Se connecterVisible tests
1
Input
"hello", "hello"Expected
True2
Input
"hello", "llohe"Expected
True3
Input
"hello", "helol"Expected
False4
Input
"hello", "lloh"Expected
False5
Input
"", ""Expected
True6
Input
"hello", "helol!"Expected
FalseFocus radio
Paused · SomaFM · Fluid