Skip to content

Commit 9388637

Browse files
committed
Runtime: 216 ms (Top 17.69%) | Memory: 50.1 MB (Top 69.23%)
1 parent c8a7c26 commit 9388637

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1+
// Runtime: 216 ms (Top 17.69%) | Memory: 50.1 MB (Top 69.23%)
12
var CustomStack = function(maxSize) {
23
this.stack = new Array(maxSize).fill(-1);
34
this.maxSize = maxSize;
45
this.size = 0;
56
};
67

7-
88
CustomStack.prototype.push = function(x) {
99
if(this.size < this.maxSize){
1010
this.stack[this.size] = x;
1111
this.size++;
1212
}
1313
};
1414

15-
1615
CustomStack.prototype.pop = function() {
1716
if(this.size > 0){
1817
this.size--;
@@ -21,12 +20,11 @@ CustomStack.prototype.pop = function() {
2120
return -1;
2221
};
2322

24-
2523
CustomStack.prototype.increment = function(k, val) {
2624
let count = k >= this.size ? this.size-1 : k-1;
27-
25+
2826
while(count >= 0){
2927
this.stack[count] += val;
3028
count--;
3129
}
32-
};
30+
};

0 commit comments

Comments
 (0)