Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
There's an optimal solution for this question using a 'stack of stacks' (more li...

Will

May 30, 2022

There's an optimal solution for this question using a 'stack of stacks' (more like a map of stacks) which runs in O(1) time instead of O(logn) time with this heap solution; both solutions have the same space complexity of O(n).

Although it doesn't follow this pattern, it may be useful to understand this alternate solution (see Leetcode Hard: 895. Maximum Frequency Stack).

4

0

Comments
Comments

On this page