Back to problems

Implement stack variants and path-sum check

Object-Oriented Programming · ByteDance · Medium

Constant-Time Stacks, Streaming Median, and Upward Path Sum Company: TikTok Role: Machine Learning Engineer Topics: Stack design, heaps / online median, tree traversal, complexity trade-offs Difficulty: Medium 1) MinStack Design a stack supporting push(x), pop(), top(), and getMin() (the smallest value currently stored), with every call running in $$O(1)$$ time. Values satisfy $$-10^9 \le x \le 10^9$$; pop, top, and getMin are only invoked when the stack is non-empty. To…

Checking your access…