LeetCode Weekly Contest 273
問題文
省略
省略
C++に変換後のコードはこちら
#define main dummy_main
{}
#undef main
class Solution {
public:
VI executeInstructions(int n, VI& startPos, string s) {
VI res;
int tmp, x, y;
rep(m,s.size()){
tmp = 0;
(x, y) = (startPos[0], startPos[1]);
rep(i,m,s.size()){
if(s[i]=='U') x--;
if(s[i]=='D') x++;
if(s[i]=='L') y--;
if(s[i]=='R') y++;
if(x < 0 || y < 0 || x >= n || y >= n) break;
tmp++;
}
res.push_back(tmp);
}
return res;
}
};
Current time: 2024年05月18日23時44分45秒
Last modified: 2022年01月02日03時40分30秒 (by laycrs)
Tags: Competitive_Programming_Incomplete LeetCode
トップページに戻る
Logged in as: unknown user (not login)