Container with Most Water (Python)

Python Interview with a FAANG engineer

Watch someone solve the max water in well problem in an interview with a FAANG engineer and see the feedback their interviewer left them. Explore this problem and others in our library of interview replays.

Python interview with a FAANG engineer: Max water in well

Interview Summary

Problem type

Max water in well

Interview question

  1. Write a stack class that keeps track of the minimum value in the stack.
  2. Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.

Read more about the questions

Interview Feedback

Feedback about Adequate Gyroscope (the interviewee)

Advance this person to the next round? Yes

How were their technical skills?

4/4

How was their problem-solving ability?

4/4

What about their communication ability?

4/4

Nothing particular. Maybe it can be a bit faster on typing out the solutions, but I think overall the candidate did well! He was able to walk through the test cases in detail and think of the solution in a reasonable timeframe.

Feedback about Festive Tsunami (the interviewer)

Would you want to work with this person? Yes

How excited would you be to work with them?

4/4

How good were the questions?

4/4

How helpful was your interviewer in guiding you to the solution(s)?

4/4

He was really nice and patient. And also explained why he conducts interviews with two questions instead of one hard one.

Interview Transcript

Festive Tsunami: Hello.

Adequate Gyroscope: Hey. Can you hear me?

Festive Tsunami: Yeah, I can hear you, can you hear me?

Adequate Gyroscope: Yes, I can hear you loud and clear.

Festive Tsunami: Cool. So yeah, let's start our mock interview. I'll introduce myself first. I'm a senior engineer in one of the software companies. And then they supervise the design doing my own design. My team is basically focused on the data engineering and big data part.

Adequate Gyroscope: Nice.

Festive Tsunami: Do you want to talk?

Adequate Gyroscope: Yeah, I am a software engineer with about 12 years of experience. I have a couple of interviews lined up. I have 10 days. In 10 days, I have an Amazon interview lined up for me at level three and two and level three, depending on how the interview goes. So yeah, this is my first time using interviewing.io.

Festive Tsunami: I gotcha. Sounds good. So let's jump right into the question. Which language do you use?

Adequate Gyroscope: I use Java and Python. So for this interview, I have chosen Python because of its syntax.

Festive Tsunami: Alright. So, the first question you just need to implement this class. In the meantime, is the question clear enough?

Adequate Gyroscope: Okay, yeah, just give me a minute to go through it. So, I have to design a stack that supports push on top and retrieving the minimum element in constant time to push on top and min stack class. Manage circles, initialize it, pushes the element and removes elements from the top of the stack top. The top element of the stack gets is the minimum element in the stack, okay. This is the class definition I have already created.

Festive Tsunami: Yeah. Okay, is it clear or do you need an example?

Adequate Gyroscope: Yeah, let's go with an example. Here I can ok.

Festive Tsunami: So, for example, if you push two and you push one, you push three, then here, what do you do? When you do top, you should return three. When you do get minimum, you should return one. And then for example if I do minus 1 here, then it should return minus one. So if I pop, that you should return one again, because that will be the minimum previously.

Adequate Gyroscope: Okay, alright. I said okay. So, if it was a normal stack, I can just use the Python list itself. So I can append towards the end of the list for the constant time append and constant time pop. The top element is also possible with lists and I can directly access the last element in the list that you can make the top part of it. So that's also constant and retrieving the minimum element in constant time. For the retrieving of the minimum, I have to keep track of all the elements that I have pushed in the stack and what is the running minimum I can just have the running minimum. Because in that example, that he said, if minus one came into play, minus one became minimum. So, once it popped out then one will become minimum. So, I have to have the history of the minimum.

... [Transcript continues with details of coding implementation and discussions on algorithm optimization] ...

Conclusion

In this mock interview, Adequate Gyroscope demonstrated strong problem-solving skills and technical knowledge during discussions around data structures and algorithms. The interviewer provided positive feedback on communication and technical abilities, suggesting the candidate is well-prepared for upcoming interviews.