Data Structures & AlgorithmsHardCAT · GATE CS
Problem: The number of ways to split a line of 6 people into 2 groups of 3 (groups are distinguishable by their first member, so each split is counted once as an unordered pair of groups) is what value?
- A. 20
- B. 15
- C. 10
- D. 5
Correct answer: C. 10
Fix person 0; choosing the other 2 members of that group from 5 people gives C(5,2) = 10 unordered splits. C(6,3) = 20 counts each split twice, C(6,2) = 15 uses the wrong group, and 5 picks only one partner.
More Coding Interview Problems questions
- Problem: The string "racecar" is compared with its reverse position by position. How many positions have matching characters?
- Problem: Starting with the number 1, double it and add 1 repeatedly. What is the value after the 10th doubling step (starting value 1, 10…
- Problem: The array [2, 4, 3, 1, 6, 5] is partitioned into the largest possible number of consecutive chunks such that after sorting each…
- Problem: A string of length 4 over {0, 1} has an even number of 1s. How many such strings are palindromes?
- Problem: The product 2^3 · 3^2 · 5^1 · 7^2 has how many positive divisors?
- Problem: For the array [1, 3, 5, 7, 9], how many subarrays have an average equal to 5?