id 1414379912 Time: 3 ms MemUsage: 2.1 MB
This commit is contained in:
13
leetcode/robot-return-to-origin/solution_1414379912.rs
Normal file
13
leetcode/robot-return-to-origin/solution_1414379912.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user