File tree 2 files changed +40
-1
lines changed
2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 1
- # 1,509 LeetCode solutions in JavaScript
1
+ # 1,510 LeetCode solutions in JavaScript
2
2
3
3
[ https://leetcodejavascript.com ] ( https://leetcodejavascript.com )
4
4
1337
1337
1733|[ Minimum Number of People to Teach] ( ./solutions/1733-minimum-number-of-people-to-teach.js ) |Medium|
1338
1338
1734|[ Decode XORed Permutation] ( ./solutions/1734-decode-xored-permutation.js ) |Medium|
1339
1339
1735|[ Count Ways to Make Array With Product] ( ./solutions/1735-count-ways-to-make-array-with-product.js ) |Hard|
1340
+ 1736|[ Latest Time by Replacing Hidden Digits] ( ./solutions/1736-latest-time-by-replacing-hidden-digits.js ) |Easy|
1340
1341
1748|[ Sum of Unique Elements] ( ./solutions/1748-sum-of-unique-elements.js ) |Easy|
1341
1342
1749|[ Maximum Absolute Sum of Any Subarray] ( ./solutions/1749-maximum-absolute-sum-of-any-subarray.js ) |Medium|
1342
1343
1752|[ Check if Array Is Sorted and Rotated] ( ./solutions/1752-check-if-array-is-sorted-and-rotated.js ) |Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 1736. Latest Time by Replacing Hidden Digits
3
+ * https://leetcode.com/problems/latest-time-by-replacing-hidden-digits/
4
+ * Difficulty: Easy
5
+ *
6
+ * You are given a string time in the form of hh:mm, where some of the digits in the string
7
+ * are hidden (represented by ?).
8
+ *
9
+ * The valid times are those inclusively between 00:00 and 23:59.
10
+ *
11
+ * Return the latest valid time you can get from time by replacing the hidden digits.
12
+ */
13
+
14
+ /**
15
+ * @param {string } time
16
+ * @return {string }
17
+ */
18
+ var maximumTime = function ( time ) {
19
+ const result = time . split ( '' ) ;
20
+
21
+ if ( result [ 0 ] === '?' ) {
22
+ result [ 0 ] = result [ 1 ] === '?' || result [ 1 ] <= '3' ? '2' : '1' ;
23
+ }
24
+
25
+ if ( result [ 1 ] === '?' ) {
26
+ result [ 1 ] = result [ 0 ] === '2' ? '3' : '9' ;
27
+ }
28
+
29
+ if ( result [ 3 ] === '?' ) {
30
+ result [ 3 ] = '5' ;
31
+ }
32
+
33
+ if ( result [ 4 ] === '?' ) {
34
+ result [ 4 ] = '9' ;
35
+ }
36
+
37
+ return result . join ( '' ) ;
38
+ } ;
You can’t perform that action at this time.
0 commit comments