Tech Screen
Questions:
Question 1: Range Sum of a Binary Tree
I clarified the requirements upfront, discussing multiple approaches and getting buy-in from the interviewer. I also proposed test cases and edge cases to consider.
The question went smoothly. The interviewers appreciated my clarifying questions (e.g., whether the tree was a binary tree or a binary search tree, and how to handle an empty tree). After agreeing on an approach, I coded it up quickly and walked through a test case. I also discussed the time complexity but almost tripped up—I initially said O(log N), but I caught myself and clarified that the worst-case complexity is actually O(N) if all nodes fall within the given range (only caught this because he asked).
Question 2: Kth Largest Element in an Array
I started by discussing the naive approach of sorting the array and returning the kth largest element, explaining why it's inefficient. I then introduced the heap-based solution and its complexity. The interviewer asked if we could do better, so I explained Quickselect, how it works, and its average and worst-case time complexity. The interviewer seemed pleased and asked me to code the heap solution. I implemented it quickly and began walking through a test case when I realized an issue: when k=0, the largest element should be returned. I was momentarily confused but kept verbalizing my thought process. The interviewer prompted me to consider what happens when k=0,1,2,3, which helped me recognize that I needed to adjust the index by adding an offset (k+1 largest). I fixed the code, and the interviewer said it looked good. We ran out of time before fully walking through all test cases.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.
Virtual Onsite
Coding 1 Q1 - Max consecutive ones variant. Instead of a binary array, input is "W" and "H" and the question is to optimize the length of the continuous time off given a PTO limit as input.
Clarified questions and discussed sliding window implementation. Talked about the time and space complexity and asked about edge cases. Coded this up quickly and started walking through a test case. The sample test case interviewer provided was kinda long (7 indices I think). Had to go through each line and updated the variables with their current state. Caught a bug during this and fixed it (think using == instead of <). Interviewer said all looked good and we moved to the next question.
Q2 - Similar to maximum profit question but with airline tickets. Was explaining the approach and got tripped as I figured I’d have to keep a minimum of the return ticket while iterating (I realized this was wrong and explained that I can’t buy a return ticket before a departure one). Interviewer said correct, so how do I approach this? This was a really easy question and I was somehow tripped and overcomplicated it. I was constantly talking and verbalizing my thoughts but I think we had like 8 minutes left and he said to just code what I was explaining. Ended up coding a solution that worked but used extra space unnecessarily and was mentally defeated. (Piece of advice: treat each round as a black box and try not to think about it in other rounds as it may affect your performance).
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.
Coding 2 Q1 - Evaluate a^b without any function.
I absolutely killed this question. Clarifying questions, time and space complexity, test cases to cover all 4 possible cases. Coded it up and ran through two test cases. The second test case had a large power so took time going over all iterations. Absolutely killed this question.
Q2 - Moving median in an array. This one caught me by surprise and I was thinking of how I’d approach it while verbalizing my thoughts. I proposed a sliding window approach and said I’d somehow figure out a way to sort the elements in each window as that’s how I’d get the median. Interviewer interjected and said no sorting—I think he was trying to give hints but I had a hard time understanding him. While I could have solved this, just thinking about my mistake in the first round and with this question made things worse. Eventually decided to create a helper function and abstracted away finding the median and then the main function to cover iterating through and passing of the right window slice. Talked about the complexity of that and then he asked how I would implement the helper function—I couldn’t immediately think of a way without sorting (was thinking quickselect since we know the size of the window and can get the middle element if we used its index as the pivot) but even I knew this was overreaching and overcomplicating it. He then said we could use two heaps (min and max) and explained how it’ll work.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.
System Design
Asked to design a social media news feed. This went really well and followed the hello interview format. I kept cool and just talked through and sometimes paused to ask questions and discussed tradeoffs. Was trying to maintain my cool but couldn’t stop thinking about the mistakes I made in the coding rounds. I think this round went better than I expected as I only studied for a short time but made sure to understand the different tech and how and where to use them. Interviewer seemed pleased and I was able to answer his follow-ups. I practically drove the discussion.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.
Behavioral
This went well and the interviewer and I had a really nice chat and even went past time (not that this would be an indication of my performance but rather that we had a nice discussion).
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.
Shout out to coding with Minmer - Hopefully we make it next time around!