Skip to content

Commit 2cbc0f9

Browse files
Create Latest Time You Can Obtain After Replacing Characters.cpp
1 parent 56013a6 commit 2cbc0f9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution {
2+
public:
3+
string findLatestTime(string s) {
4+
if(s[0]=='?' && s[1]=='?' && s[3]=='?' && s[4]=='?') return "11:59";
5+
if(s[0]=='?'){
6+
if( s[1]=='0' || s[1]=='?' || s[1]=='1')
7+
s[0]='1';
8+
else s[0]='0';
9+
}
10+
if(s[1]=='?' && s[0]=='1' ) s[1]='1';
11+
if(s[1]=='?' && s[0]=='0')s[1]='9';
12+
if(s[3]=='?') s[3]='5';
13+
if(s[4]=='?') s[4]='9';
14+
15+
return s;
16+
17+
}
18+
};

0 commit comments

Comments
 (0)