Back to Start

A robot starts at point (0, 0) and follows movement commands. The function judge_circle receives a string moves, where U moves up, D moves down, L moves left, and R moves right. Check whether the robot ends up back at the starting point after all commands. Return True if it returns, otherwise return False.

Примеры

Ввод
["UDLRUD"]
Вывод
True
Ввод
["LLRU"]
Вывод
False
Ввод
["UD"]
Вывод
True

Нужно реализовать

def judge_circle(moves: str) -> bool:

Теги

strings
PostgreSQLv16

Aquí aparecerá el resultado de la ejecución del código

Visible tests
1
Input
"UDLRUD"
ExpectedTrue
2
Input
"LLRU"
ExpectedFalse
3
Input
"UD"
ExpectedTrue
4
Input
""
ExpectedTrue
5
Input
" "
ExpectedTrue
6
Input
"a"
ExpectedTrue
Focus radio
Paused · SomaFM · Fluid