You are viewing a single comment's thread. Return to all comments →
Hi, your idea is cool!
+
StackNode { int max int elementsAboveMax = 1 } push { if (stack.peek.max < val) stack.push( StackNode(val) ) else stack.peek.elementsAboveMax++ } pop { if (--stack.peek.elementsAboveMax == 0) stack.pop() } print { sout( stack.peek.max ) }
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Element
You are viewing a single comment's thread. Return to all comments →
Hi, your idea is cool!
+