ORIGINAL CODING QUESTION
Committee selection count
Count unordered ways to choose exactly r different people from n. Return 0 for r>n. People are distinct and order does not matter.
Original exercise · medium. Editorial role relevance does not imply a company has asked this question.
Input and output
n r.
Constraints
0 ≤ n,r ≤ 25; the result fits signed 32-bit.
Example 1
Input
5 2
Output
10
There are ten unordered pairs.
Example 2
Input
3 4
Output
0
Choosing four from three is impossible.
Explain your approach
Explain your time and auxiliary space complexity. Which input makes your algorithm work hardest?
Private grading inputs, expected outputs and canonical reference implementations are withheld. Authored expected outputs were cross-checked with independent reference oracles; compiler/runtime behavior still needs a verified execution provider.
Hint 1
Choosing or skipping one person creates two smaller cases.
Hint 2
Pascal’s identity combines adjacent counts.
Hint 3
Use one row updated from right to left.
Practice this question
Save your work privately, explain decisions and return to your revision queue.
Open practice workspaceBrowse the question library →