Open In App

Google Interview Experience for SDE

Last Updated : 07 Aug, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

During my interview, I had two technical rounds, each lasting 45 minutes. In both rounds, I had to write my solutions in a document.

In the first round, question was based on topological sorting. The task was to calculate the number of semesters needed to complete all the courses, with the condition that the second course must be finished before the first. To solve this, I used depth-first search (DFS).

The interviewer then asked a follow-up question: “How many courses can you finish in one semester?” To make the most of each semester, I focused on courses without any prerequisites. This way, I could complete as many courses as possible in a single semester.

In the second round, the problem was about selecting and pairing cartons. From an incoming stream, I needed to choose three cartons, ensuring that the difference between any two cartons was not more than a given value ‘d.’ To solve this, I followed these steps:

  1. Storing in a Queue: As cartons arrived in the stream, I used a Queue to keep them in the order they came.
  2. Sorting and Extracting : I found the smallest and largest carton values by continuously removing elements from the front and back of the Queue, respectively. I kept the cartons in ascending order.
  3. Forming Pairs of Three : With the sorted carton values, I checked for suitable pairs within the ‘d’ difference while going through the Queue. When I found a valid pair, I stored the result in a Map. I then removed the first two cartons from the Queue and completed the trio with the next available carton.

Top 10 tips for better Google interview :

  • Make sure you understand the problem well by repeating instructions and asking for examples.
  • Divide the problem into smaller parts for better understanding.
  • Start with a basic solution to demonstrate your thought process, even if it’s not the most efficient.
  • If possible, optimize your approach, considering the time and space needed.
  • Share your approach, time, and space complexity with the interviewer before implementing your solution.
  • If you get stuck, explain your thought process and seek guidance from the interviewer.
  • Avoid making assumptions, be interactive, and ask for clarifications when needed.
  • Test your solutions with examples to handle different cases.
  • Be aware of any constraints or special conditions given in the problem.
  • Write your code neatly, add comments to explain important parts, and include time and space complexity details for each function.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads