LinkedIn Screening Round
Question Details
I appeared for Linkedin phone screening round. Team: Platform and Infra team Question asked: Implement a max stack class, that would allow you to do normal stack operation along with max...
Full Details
I appeared for Linkedin phone screening round.
Team: Platform and Infra team
Question asked: Implement a max stack class, that would allow you to do normal stack operation along with max operation such as peek and pop.
Expectation: All operation except popMax(), should be around O(n) complexity.
class MaxStack:
\tdef __init():
\t\tpass
\t\t
\tdef push(int v):
\t\tpass
\t\t
\tdef pop():
\t\tpass
\t\t
\tdef peek():
\t\tpass
\t\t
\tdef popMax():
\t\tpass
\t\t
\tdef peekMax():
\t\tpass
My approach:
- I suggested a combination of linked-list/stack with stack/max-heap respectively
- The discussion I had with the interviewer, he finalised on the stack + max heap approach
- I completed the code within the timelimit, the interviewer asked me to make the code production ready
Outcome: I thought the interview went well. But the recuriter told me that I was
rejected.
The code was supposed to be done on a coderpad link. But linkedin does not allow you to run the code. While my approach was right, the code was working (verified post the interview). But for some reason I got
rejected. Any idea what happened?
About This Question
This is a reported interview question from a linkedin interview for a swe role during the oa round reported in 2025.
It covers the following topics: Backtracking, Heap, Linked List, Stack .