[Go] Clean Code


  • 0
    N
    func judgeCircle(moves string) bool {
    	x, y := 0, 0
    
    	for _, v := range moves {
    		switch v {
    		case 'U':
    			y--
    		case 'D':
    			y++
    		case 'L':
    			x--
    		case 'R':
    			x++
    		}
    	}
    	return x == 0 && y == 0
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.