LinkedIn Screening Round
Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2025-02-02Added By Anonymous
Source: Link
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.
1class MaxStack:
2
3 def __init():
4 pass
5
6 def push(int v):
7 pass
8
9 def pop():
10 pass
11
12 def peek():
13 pass
14
15 def popMax():
16 pass
17
18 def peekMax():
19 passMy 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?