Data Structures & AlgorithmsHardCAT · TCS NQT
Problem: A row of 5 seats is filled by 3 distinct people, leaving 2 seats empty. How many arrangements are possible if the empty seats must be adjacent?
- A. 60
- B. 6
- C. 48
- D. 24
Correct answer: D. 24
The adjacent empty pair can sit in 4 places and the 3 people fill the rest in 3! = 6 ways: 24. Without the constraint P(5,3) = 60, 6 forgets the 4 placements, and 48 treats the two empty seats as distinguishable.
More Coding Interview Problems questions
- Problem: The sum of the squares of the odd numbers from 1 to 19 is what value?
- Problem: A grid of 3 rows and 3 columns is filled with the numbers 1 to 9 row by row. A "line" is a complete row, column or main diagonal…
- Problem: What is the number of lattice points (x, y) with x, y ≥ 0 and x + y ≤ 5?
- Problem: The array [5, 1, 4, 2, 3] is sorted by repeatedly swapping adjacent elements that are out of order (bubble sort). How many passes…
- Problem: The Hamming weight (number of 1-bits) of each integer from 0 to 15 is summed. What is the total?
- Problem: A set of letters {A, B, C, D, E} is arranged in a row. How many arrangements have A immediately to the left of B?