MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / canShrink

Function canShrink

javascript/0084-largest-rectangle-in-histogram.js:118–119  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

116 const isCurrHeightLess = ([prevIndex, prevHeight], currHeight) =>
117 currHeight < prevHeight;
118 const canShrink = () =>
119 isCurrHeightLess(stack[stack.length - 1], heights[index]);
120 while (stack.length && canShrink()) {
121 /* Time O(N + N) */
122 const [_index, _height] = stack.pop();

Callers 1

fillStackFunction · 0.70

Calls 1

isCurrHeightLessFunction · 0.85

Tested by

no test coverage detected