Data Structures & AlgorithmsModerateTCS NQT Digital · Infosys
Problem: Five customers with service times 5, 3, 8, 2, 4 (in arrival order) are served by two tellers. Each customer goes to whichever teller becomes free first (ties go to teller 1), and all arrive at time 0. What is the time at which the last customer finishes?
- A. 22
- B. 17
- C. 11
- D. 7
Correct answer: C. 11
Teller 1 takes 5, teller 2 takes 3; at t = 3 teller 2 takes 8 (ends 11); at t = 5 teller 1 takes 2 (ends 7) and then 4 (ends 11), so the last finish is 11. A single teller would need 22, alternating customers between tellers gives teller 1 5 + 8 + 4 = 17, and 7 is only customer 4's finish.
More Coding Interview Problems questions
- Problem: How many ordered pairs (a, b) of positive integers satisfy a × b = 36 with a ≤ 100 and b ≤ 100?
- Problem: How many non-negative integer solutions (x, y, z) satisfy x + y + z = 10?
- Problem: How many integer solutions (x, y, z) with x, y, z ≥ 1 satisfy x + y + z = 10?
- Problem: A derangement is a permutation with no fixed point. How many derangements of 5 objects exist?
- Problem: How many binary trees (distinct shapes, ignoring labels) can be formed with 6 nodes?
- Problem: Count the integers from 1 to 64 whose binary representation has an even number of 1-bits.