https://leetcode.com/problems/robot-return-to-origin/description/
/**
* @param {string} moves
* @return {boolean}
*/
var judgeCircle = function (moves) {
const hashMap = {
U: 0,
D: 0,
L: 0,
R: 0,
};
for (const move of moves) {
hashMap[move] += 1;
}
return hashMap['U'] === hashMap['D'] && hashMap['L'] === hashMap['R'];
};
Runtime 121 ms Beats 43.44%
Memory 44.7 MB Beats 40.87%