Skip to content

Commit dcb01b6

Browse files
authored
Update 1904-the-number-of-full-rounds-you-have-played.js
1 parent 75df5ad commit dcb01b6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

1904-the-number-of-full-rounds-you-have-played.js

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/**
2+
* @param {string} startTime
3+
* @param {string} finishTime
4+
* @return {number}
5+
*/
6+
const numberOfRounds = function(startTime, finishTime) {
7+
let start = 60 * parseInt(startTime.slice(0, 2)) + parseInt(startTime.slice(3))
8+
let finish = 60 * parseInt(finishTime.slice(0, 2)) + parseInt(finishTime.slice(3));
9+
if (start > finish) finish += 60 * 24; // If `finishTime` is earlier than `startTime`, add 24 hours to `finishTime`.
10+
return Math.max(0, Math.floor(finish / 15) - Math.ceil(start / 15)); // floor(finish / 15) - ceil(start / 15)
11+
};
12+
13+
// another
14+
115
/**
216
* @param {string} startTime
317
* @param {string} finishTime

0 commit comments

Comments
 (0)