MCPcopy Index your code
hub / github.com/neetcode-gh/leetcode / push

Method push

javascript/0155-min-stack.js:24–31  ·  view source on GitHub ↗

* @param {number} val * @return {void}

(val, { minStack } = this)

Source from the content-addressed store, hash-verified

22 * @return {void}
23 */
24 push(val, { minStack } = this) {
25 this.stack.push(val); /* Space O(N) */
26
27 const isMinEmpty = !minStack.length;
28 const hasNewMin = val <= this.top(minStack);
29 const canAddMin = isMinEmpty || hasNewMin;
30 if (canAddMin) minStack.push(val); /* Space O(N) */
31 }
32
33 /**
34 * @return {void}

Callers 15

dfsFunction · 0.45
backTrackFunction · 0.45
bfsFunction · 0.45
dfsFunction · 0.45
removeDuplicatesFunction · 0.45
threeSumFunction · 0.45
dailyTemperaturesFunction · 0.45
bfsFunction · 0.45
rightSideViewFunction · 0.45
buildGraphFunction · 0.45
checkNeighborsFunction · 0.45
dfsFunction · 0.45

Calls 1

topMethod · 0.95

Tested by

no test coverage detected