Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb9c1752

Browse files
committed
Add solution #2437
1 parente433db1 commitb9c1752

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-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,946 LeetCode solutions in JavaScript
1+
#1,947 LeetCode solutions in JavaScript
22

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

@@ -1838,6 +1838,7 @@
18381838
2433|[Find The Original Array of Prefix Xor](./solutions/2433-find-the-original-array-of-prefix-xor.js)|Medium|
18391839
2434|[Using a Robot to Print the Lexicographically Smallest String](./solutions/2434-using-a-robot-to-print-the-lexicographically-smallest-string.js)|Medium|
18401840
2435|[Paths in Matrix Whose Sum Is Divisible by K](./solutions/2435-paths-in-matrix-whose-sum-is-divisible-by-k.js)|Hard|
1841+
2437|[Number of Valid Clock Times](./solutions/2437-number-of-valid-clock-times.js)|Easy|
18411842
2444|[Count Subarrays With Fixed Bounds](./solutions/2444-count-subarrays-with-fixed-bounds.js)|Hard|
18421843
2460|[Apply Operations to an Array](./solutions/2460-apply-operations-to-an-array.js)|Easy|
18431844
2462|[Total Cost to Hire K Workers](./solutions/2462-total-cost-to-hire-k-workers.js)|Medium|
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* 2437. Number of Valid Clock Times
3+
* https://leetcode.com/problems/number-of-valid-clock-times/
4+
* Difficulty: Easy
5+
*
6+
* You are given a string of length 5 called time, representing the current time on a digital
7+
* clock in the format "hh:mm". The earliest possible time is "00:00" and the latest possible
8+
* time is "23:59".
9+
*
10+
* In the string time, the digits represented by the ? symbol are unknown, and must be replaced
11+
* with a digit from 0 to 9.
12+
*
13+
* Return an integer answer, the number of valid clock times that can be created by replacing
14+
* every ? with a digit from 0 to 9.
15+
*/
16+
17+
/**
18+
*@param {string} time
19+
*@return {number}
20+
*/
21+
varcountTime=function(time){
22+
lethourChoices=1;
23+
letminuteChoices=1;
24+
25+
if(time[0]==='?'&&time[1]==='?'){
26+
hourChoices=24;
27+
}elseif(time[0]==='?'){
28+
hourChoices=time[1]<='3' ?3 :2;
29+
}elseif(time[1]==='?'){
30+
hourChoices=time[0]==='2' ?4 :10;
31+
}
32+
33+
if(time[3]==='?'&&time[4]==='?'){
34+
minuteChoices=60;
35+
}elseif(time[3]==='?'){
36+
minuteChoices=6;
37+
}elseif(time[4]==='?'){
38+
minuteChoices=10;
39+
}
40+
41+
returnhourChoices*minuteChoices;
42+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp