YOE : 4 Years Current company : FAANG
I applied several times through referrals but received only automated rejection emails. Then, in June, I randomly applied to multiple suitable positions via the career portal and received the online assessment link.
3 Questions needed to be solved in 120 minutes.
[First question]
A code snippet was given where it was not producing correct output for all the inputs. At max 2 lines can be modified of that snippet. I had to debug and fix the code. Don't remember the exact code snippet but the solution was to replace one if keyword with while keyword.
[Second question] Easy question. Don't remember the question.
[Third question] There is a queue of N cars waiting at the filling station. 3 fuel dispensers, x, y, z. When a car arrives at the front of the queue, the driver can choose to go to any dispenser not occupied. If all unoccupied dispensers have less than required by the driver, he has to wait. If more than one dispenser has the required liter, the driver chooses the one labeled with the smallest letter. Calculate the max amount of waiting time. If all the cars cannot be refueled then return -1.
Assume taking one liter of fuel takes exactly one second? example A[2,8,4,3,2], x= 7, y=11, z=3, then cars will be waiting 0, 0, 2, 2, 8 seconds.
So the max waiting time is 8 from [0,0,2,2,8] in this example.
Reasoning:
let 'w' = wait time A[0] = 2 --> goes to x. w += 0; fuel remaining at x = 7 - 2 = 5 -> had to wait 0 seconds A[1] = 8 --> goes to y. w += 0; fuel remaining at y = 11 - 8 = 3 -> had to wait 0 seconds A[2] = 4 --> can't go to z (only 3 liters of fuel) so wait till 'x' is available; w += 2; fuel remaining at x = 5 - 4 = 1 -> had to wait 2 seconds because of A[0]. A[3] = 3 --> goes to z. w += 0. fuel remaining at z = 3 - 3 = 0 -> has to wait 2 seconds because of A[2] had to wait 2 seconds. A[4] = 2 --> can't go to x and z (not enough fuel) so wait till 'y' is available; so is wait time += 8 now? fuel remaining at y = 3 - 2= 1 -> Had to wait 8 seconds
Solved the above problem using PriorityQueue.
[First question]
Given a circular array A that only contains 0,1. You have to find the number of alternating subarrays of size K.
For example, If A= [0,1,0,0,1,0,1] and K=3 then the answer will be 5 and the subarrays will be -
[0,1,0] -> index 0 to 2[0,1,0] -> index 3 to 5[1,0,1] -> index 4 to 6[0,1,0] -> index 5 to 1 -> because it's a circular array[1,0,1] -> index 6 to 2 -> because it's a circular array[Second question] Longest Substring Without Repeating Characters
For both of the questions I solved using sliding window. I was asked to come up with only the approach, time and space complexity for the second question.
[First question] Restore IP Addresses
I had to execute the code on Codility and verify it using the inputs provided by the interviewer. Additionally, the interviewer asked for suggestions on how to improve the code's performance.
[Second question] Design a chat application like WhatsApp.
I had a great start on the design question but I wasn't able to solve some of the questions asked by the interviewer due to time.
Some questions related to my role and work in my current company.
[First question] Design a Star rating system like in Amazon.
Behavioural questions like - `
[First question] Group Anagrams
Update Got automated rejection on 2 August. They haven't provided any feedback why I was rejected. My guess is that the 2nd onsite round contributed to the rejection. Looks like I need to improve.