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
PostgreSQLv16

Tutaj pojawi się wynik wykonania kodu

Visible tests
1
Input
"hello", "hello"
ExpectedTrue
2
Input
"hello", "llohe"
ExpectedTrue
3
Input
"hello", "helol"
ExpectedFalse
4
Input
"hello", "lloh"
ExpectedFalse
5
Input
"", ""
ExpectedTrue
6
Input
"hello", "helol!"
ExpectedFalse
Focus radio
Paused · SomaFM · Fluid