Google India screening.
Company: Google
Role: unknown
Interview Stage: Phone Screen
Location: India
Year: unknown
Original Post Content:
Hi LC community
I had my first Google screening round today. The question was to build an integer which is the maximum subsequence from a subarray of size K. E.g., Array is [4, 9, 0, 2] and k = 2. Answer: 92.
I had never seen this before, so I gave a DP solution with memoization where I add my i'th index number to the result and decrement k, or don't add and increment the index. I gave the time complexity as k X O(n). The interviewer was not happy and asked me to optimize.
I gave an approach where I choose from the left with at least k-1 elements to the right, then again take the max after that index. Solved using a heap, the interviewer agreed but asked to optimize more and even gave a hint which I did not understand. Basically, I had to use a monotonic stack and do it in O(n).
Seems this is the end of my Google journey for now.
Thanks