可以在线制作简历的网站,上街网络推广,云南建设厅网站资质证书查询,品牌推广的作用力扣题-12.4
[力扣刷题攻略] Re#xff1a;从零开始的力扣刷题生活
力扣题1#xff1a;657. 机器人能否返回原点
解题思想#xff1a;进行统计即可 class Solution(object):def judgeCircle(self, moves)::type moves: str:rtype: bool从零开始的力扣刷题生活
力扣题1657. 机器人能否返回原点
解题思想进行统计即可 class Solution(object):def judgeCircle(self, moves)::type moves: str:rtype: booldic {U: 0, D: 0, R: 0, L: 0}for move in moves:if move U:dic[U] 1elif move D:dic[D] 1elif move R:dic[R] 1elif move L:dic[L] 1return dic[U] dic[D] and dic[R] dic[L]
class Solution {
public:bool judgeCircle(string moves) {std::unordered_mapchar, int counts{{U, 0}, {D, 0}, {R, 0}, {L, 0}};for (char move : moves) {if (move U) {counts[U];} else if (move D) {counts[D];} else if (move R) {counts[R];} else if (move L) {counts[L];}}return counts[U] counts[D] counts[R] counts[L];}
};