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

Difficulty: EASY
Starter code: class Solution:
    def judgeCircle(self, moves: str) -> bool:


Solutions:
class Solution:

	def judgeCircle(self, moves):
		return moves.count('U') == moves.count('D') and moves.count('L') == moves.count('R')


class Solution:

	def judgeCircle(self, moves):
		if not moves:
			return True
		if len(moves) % 2 == 1:
			return False
		(up, left) = (0, 0)
		for move in moves:
			if move == 'U':
				up += 1
			if move == 'D':
				up -= 1
			if move == 'L':
				left += 1
			if move == 'R':
				left -= 1
		return up == 0 and left == 0


class Solution:

	def judgeCircle(self, moves):
		pos = [0, 0]
		for i in moves:
			if i == 'U':
				pos[0] = pos[0] + 1
			elif i == 'D':
				pos[0] = pos[0] - 1
			elif i == 'L':
				pos[1] = pos[1] - 1
			elif i == 'R':
				pos[1] = pos[1] + 1
		return [0, 0] == pos


class Solution:

	def judgeCircle(self, moves):
		(l, r, u, d) = list(map(moves.count, 'LRUD'))
		return l == r and u == d


class Solution:

	def judgeCircle(self, moves):
		(u, d, l, r) = map(moves.count, 'UDLR')
		return u == d and l == r


class Solution:

	def judgeCircle(self, moves):
		x = 0
		y = 0
		for move in moves:
			if move == 'L':
				x -= 1
			elif move == 'R':
				x += 1
			elif move == 'U':
				x += 1
			elif move == 'D':
				x -= 1
		if x == 0 and y == 0:
			return True
		else:
			return False