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

Commit a78a17b

Browse files
update: 补齐缺失文件
1 parent 5f01ba8 commit a78a17b

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

‎.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/*

‎src/minimum-time-difference/res.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* @param {string[]} timePoints
3+
* @return {number}
4+
*/
5+
let findMinDifference = function(timePoints) {
6+
let len = timePoints.length;
7+
if (len === 1) return 0;
8+
9+
let tarray = new Array(24*60),
10+
min = 1441,
11+
max = -1,
12+
res = 1441,
13+
prev = 0;
14+
15+
for (let i=0; i<len; i++) {
16+
let tmplist = timePoints[i].split(':'),
17+
minute = (tmplist[0]-'0')*60 + (tmplist[1]-'0');
18+
19+
if (tarray[minute]) {
20+
return 0;
21+
} else {
22+
tarray[minute] = true;
23+
}
24+
}
25+
26+
for (let i=0; i<1440; i++) {
27+
if (tarray[i]) {
28+
if (min !== 1441) {
29+
res = Math.min(res, i-prev);
30+
} else {
31+
min = i;
32+
}
33+
34+
max = Math.max(max, i);
35+
prev = i;
36+
}
37+
}
38+
39+
return Math.min(res, 24*60-max+min);
40+
};

‎src/predict-the-winner/res.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {boolean}
4+
*/
5+
let PredictTheWinner = function(nums) {
6+
let len = nums.length,
7+
res = new Array(len).fill([]);
8+
9+
for (let i=len-1; i>=0; i--) {
10+
for (let j=i; j<len; j++) {
11+
if (i==j) res[i] = nums[i];
12+
else res[j] = Math.max(nums[i]-res[j], nums[j]-res[j-1]);
13+
}
14+
}
15+
16+
return res[len-1] >= 0;
17+
};
18+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /