Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit db73f3e

Browse files
committed
Add solution #1736
1 parent 104ae4e commit db73f3e

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1,509 LeetCode solutions in JavaScript
1+
# 1,510 LeetCode solutions in JavaScript
22

33
[https://leetcodejavascript.com](https://leetcodejavascript.com)
44

@@ -1337,6 +1337,7 @@
13371337
1733|[Minimum Number of People to Teach](./solutions/1733-minimum-number-of-people-to-teach.js)|Medium|
13381338
1734|[Decode XORed Permutation](./solutions/1734-decode-xored-permutation.js)|Medium|
13391339
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|
13401341
1748|[Sum of Unique Elements](./solutions/1748-sum-of-unique-elements.js)|Easy|
13411342
1749|[Maximum Absolute Sum of Any Subarray](./solutions/1749-maximum-absolute-sum-of-any-subarray.js)|Medium|
13421343
1752|[Check if Array Is Sorted and Rotated](./solutions/1752-check-if-array-is-sorted-and-rotated.js)|Easy|
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
};

0 commit comments

Comments
 (0)