📌 📄 内容摘要:
@SomeBottle 在 Leetcode每日一题 —— 657. 机器人能否返回原点 中发帖
依旧机器人 (¬`‸´¬)
思路
其实就是简单的模拟题,根据操作模拟左右上下移动、更新坐标,最终判断是否回到原点即可。
代码
class Solution {
public:
bool judgeCircle(string moves) {
// 模拟题
int xPos=0,yPos=0;
for(char c:moves){
switch(c){
case 'R':
xPos++;
break;
case 'L':
xPos--;
break;
c...
────────── 链接信息 ──────────
🔗 论坛链接: linux.do
📎 访问地址: https://linux.do/t/topic/1900118/1
─────────────────────────────
📢 来源:LINUX DO