Skip to content

Commit 60fba22

Browse files
committed
Update siteData script and data
1 parent 8a262a0 commit 60fba22

16 files changed

+331
-1881
lines changed

.problemList.json

Lines changed: 0 additions & 1633 deletions
This file was deleted.

.problemSiteData.json

Lines changed: 294 additions & 117 deletions
Large diffs are not rendered by default.

.rufo

Whitespace-only changes.

1376-time-needed-to-inform-all-employees.kt

Lines changed: 0 additions & 22 deletions
This file was deleted.
File renamed without changes.

javascript/0682-baseball-game.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,28 @@
22
* @param {string[]} operations
33
* @return {number}
44
*/
5-
var calPoints = function (operations) {
5+
var calPoints = function(operations) {
6+
let runningSum = 0;
67
const stack = [];
7-
for(const op of operations){
8-
if(op==="+"){
9-
stack.push(stack[stack.length - 1] + stack[stack.length - 2]);
10-
}else if(op==="C"){
11-
stack.pop()
12-
}else if(op==="D"){
13-
stack.push(stack[stack.length - 1] * 2);
14-
}else{
15-
stack.push(parseInt(op))
8+
for(const o of operations) {
9+
if(o === 'C') {
10+
runningSum -= stack.pop();
11+
continue;
1612
}
13+
if(o === 'D') {
14+
const val = stack[stack.length - 1] * 2;
15+
stack.push(val);
16+
runningSum += val;
17+
continue;
18+
}
19+
if(o === '+') {
20+
const val = stack[stack.length - 1] + stack[stack.length - 2];
21+
stack.push(val);
22+
runningSum += val;
23+
continue;
24+
}
25+
stack.push(+o);
26+
runningSum += +o;
1727
}
18-
return stack.reduce((prev,curr)=>prev+curr,0)
28+
return runningSum;
1929
};

0 commit comments

Comments
 (0)