GOOGLE L3 ONSITE R3

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2025-04-28Added By Anonymous
Source: Link
🧭 Experience: unknown
✅ Outcome: unknown
💰 Compensation: unknown
📍 Location: unknown
🏢 Company: Google
🎓 Education: unknown
🎁 Benefits: unknown
📅 Offer Date: unknown

I was asked a warm up question and a main question over here. You have a class Queue with only two operations allowed in it. class Queue { Integer pop(); boolean isEmpty(); } Input : List<Queue> queues Constraints : All values inside the queue are positive integers. Warm-Up Question: You have a list of queue of size len. Return the index of the shortest queue from the list of queues with only two queue operations allowed as mentioned above. Main Question: Now, you have to find out the minimum sum of a queue from the list of the queues in the most efficient manner. Was able to solve both of them but was a bit unsure about the 2nd part that whether I did the most optimal way or not. Did use an external Deque, an array of integer sum and a variable minimum sum to process the sums. If any running sum of queue, turns out to be greater than potential minimum sum, I won't process that queue any further and discontinue the operations while not processing it in deque. Would appreciate any better solutions.
Comments