My LeetCode grinding. Trying to do a problem a day.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

12345678910111213141516171819
  1. pub fn judge_circle(moves: String) -> bool {
  2. let mut x = 0;
  3. let mut y = 0;
  4. for m in moves.chars() {
  5. match m {
  6. 'U' => x = x + 1,
  7. 'D' => x = x - 1,
  8. 'L' => y = y + 1,
  9. 'R' => y = y - 1,
  10. _ => {},
  11. }
  12. }
  13. return y == 0 && x == 0;
  14. }
  15. pub fn main() {
  16. println!("Expected: true");
  17. println!("Got: {}", judge_circle("UDRULD".to_string()));
  18. }