Skip to content

Commit 558e6ba

Browse files
add 1736
1 parent a352352 commit 558e6ba

File tree

3 files changed

+54
-59
lines changed

3 files changed

+54
-59
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|1736|[Latest Time by Replacing Hidden Digits](https://leetcode.com/problems/latest-time-by-replacing-hidden-digits/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1736.java) ||Easy|String, Greedy|
1112
|1733|[Minimum Number of People to Teach](https://leetcode.com/problems/minimum-number-of-people-to-teach/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1733.java) ||Medium|Array, Greedy|
1213
|1732|[Find the Highest Altitude](https://leetcode.com/problems/find-the-highest-altitude/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1732.java) ||Easy|Array|
1314
|1727|[Largest Submatrix With Rearrangements](https://leetcode.com/problems/largest-submatrix-with-rearrangements/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1727.java) ||Medium|Greedy, Sort|

src/main/java/com/fishercoder/solutions/Contest.java

-59
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.fishercoder.solutions;
2+
3+
public class _1736 {
4+
public static class Solution1 {
5+
public String maximumTime(String time) {
6+
StringBuilder sb = new StringBuilder();
7+
String[] strs = time.split(":");
8+
String hour = strs[0];
9+
String min = strs[1];
10+
if (hour.charAt(0) == '?') {
11+
if (hour.charAt(1) == '?') {
12+
sb.append("23");
13+
} else if (hour.charAt(1) > '3') {
14+
sb.append("1");
15+
sb.append(hour.charAt(1));
16+
} else {
17+
sb.append("2");
18+
sb.append(hour.charAt(1));
19+
}
20+
} else if (hour.charAt(0) == '0' || hour.charAt(0) == '1') {
21+
if (hour.charAt(1) == '?') {
22+
sb.append(hour.charAt(0));
23+
sb.append("9");
24+
} else {
25+
sb.append(hour);
26+
}
27+
} else if (hour.charAt(0) == '2') {
28+
if (hour.charAt(1) == '?') {
29+
sb.append("23");
30+
} else {
31+
sb.append(hour);
32+
}
33+
}
34+
sb.append(":");
35+
if (min.charAt(0) == '?') {
36+
if (min.charAt(1) == '?') {
37+
sb.append("59");
38+
} else {
39+
sb.append("5");
40+
sb.append(min.charAt(1));
41+
}
42+
return sb.toString();
43+
}
44+
sb.append(min.charAt(0));
45+
if (min.charAt(1) == '?') {
46+
sb.append("9");
47+
} else {
48+
sb.append(min.charAt(1));
49+
}
50+
return sb.toString();
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)