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 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.


