package com.fishercoder.solutions;

/**
 * 657. Judge Route Circle
 *
 * Initially, there is a Robot at position (0, 0).
 * Given a sequence of its moves, judge if this robot makes a circle,
 * which means it moves back to the original place.

 The move sequence is represented by a string.
 And each move is represent by a character.
 The valid robot moves are R (Right), L (Left), U (Up) and D (down).
 The output should be true or false representing whether the robot makes a circle.

 Example 1:
 Input: "UD"
 Output: true

 Example 2:
 Input: "LL"
 Output: false
 */

public class _657 {
    public boolean judgeCircle(String moves) {
        int hori = 0;
        int verti = 0;
        for (char c : moves.toCharArray()) {
            if (c == 'U') {
                verti++;
            } else if (c == 'D') {
                verti--;
            } else if (c == 'L') {
                hori--;
            } else if (c == 'R') {
                hori++;
            }
        }
        return verti == 0 && hori == 0;
    }
}

@@ -586,16 +586,56 @@
  _657 %7B%0A
+    public static class Solution1 %7B%0A    
     publ
@@ -677,24 +677,28 @@
 ) %7B%0A        
+    
 int hori = 0
@@ -703,24 +703,28 @@
  0;%0A        
+   
+ 
 int verti = 
@@ -722,24 +722,28 @@
  verti = 0;%0A
+    
         for 
@@ -787,16 +787,20 @@
         
+ 
+   
 if (c ==
@@ -803,24 +803,28 @@
 c == 'U') %7B%0A
+    
             
@@ -840,32 +840,36 @@
 ++;%0A            
+    
 %7D else if (c == 
@@ -887,24 +887,28 @@
             
+   
+ 
 verti--;%0A   
@@ -900,24 +900,28 @@
    verti--;%0A
+    
             
@@ -963,16 +963,20 @@
     
+    
 hori--;%0A
     
@@ -967,24 +967,28 @@
     hori--;%0A
+    
             
@@ -1022,24 +1022,28 @@
             
+    
 hori++;%0A    
@@ -1042,34 +1042,42 @@
 ++;%0A            
+   
+ 
 %7D%0A
+    
         %7D%0A      
@@ -1078,16 +1078,20 @@
         
+ 
+   
 return v
@@ -1110,20 +1110,30 @@
  hori == 0;%0A
+        %7D%0A
     %7D%0A%7D%0A

refactor 657