-
-
Notifications
You must be signed in to change notification settings - Fork 297
/
Copy path1323.cpp
30 lines (30 loc) · 805 Bytes
/
1323.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
__________________________________________________________________________________________________
sample 0 ms submission
class Solution {
public:
int maximum69Number (int num) {
string x = to_string(num);
for(int i = 0;i < x.size();++i) {
if(x[i] == '6') {
x[i] = '9';
break;
}
}
return stoi(x);
}
};
__________________________________________________________________________________________________
class Solution {
public:
int maximum69Number (int num) {
string temp = to_string(num);
int six = 0;
six = temp.find('6');
if (six != -1 ) {
temp[six] = '9';
return stoi(temp);
}
return num;
}
};
__________________________________________________________________________________________________