luoheng
10/6/2019 - 8:23 AM

judgeCircle

func judgeCircle(moves string) bool {
    w, h := 0, 0
    for _, c := range moves {
        switch c {
        case 'U':
            w++
        case 'D':
            w--
        case 'L':
            h++
        case 'R':
            h--
        }
    }
    return w == 0 && h == 0
}