id 1414379912 Time: 3 ms MemUsage: 2.1 MB

This commit is contained in:
2024-10-22 10:19:46 +09:00
parent 293d936840
commit b53a38200f

View File

@@ -0,0 +1,13 @@
impl Solution {
pub fn judge_circle(moves: String) -> bool {
moves.chars().fold((0, 0), |(x, y), c| {
match c{
'U' => (x, y + 1),
'D' => (x, y - 1),
'L' => (x - 1, y),
'R' => (x + 1, y),
_ => unreachable!()
}
}) == (0, 0)
}
}