LeetCode Weekly Contest 243
問題文
省略
省略
C++に変換後のコードはこちら
#define main dummy_main
{}
#undef main
class Solution {
public:
string maxValue(string n, int x) {
int N = n.size();
if(n[0] == '-'){
rep(i,1,N) if(n[i] - '0' > x) break;
n = n.substr(0,i) + (char)(x+'0') + n.substr(i);
} else {
rep(i,N) if(n[i] - '0' < x) break;
n = n.substr(0,i) + (char)(x+'0') + n.substr(i);
}
return n;
}
};
Current time: 2024年04月26日00時13分45秒
Last modified: 2021年06月07日19時37分27秒 (by laycrs)
Tags: Competitive_Programming_Incomplete LeetCode
トップページに戻る
Logged in as: unknown user (not login)