All practice tasks

Coding (Algo)

Count Review Panels

Combinatorics · Medium

A review coordinator chooses a panel of k people from n distinct eligible reviewers. Panel ordering is irrelevant. It needs an exact count without enumerating each possible group or rounding large factorial values.

Return the exact number of distinct unordered panels of size k drawn from n reviewers.

Input

Call

  • Implement solve(input) and return the result. The provided adapter handles JSON input and output.

Input shape

{ n: integer, k: integer }

Fields

  • n is the number of distinct reviewers. k is the requested number of reviewers on one panel.

Output

Return value

  • Return C(n,k) as a safe JSON integer. Return 0 when k > n.
  • Choosing nobody has one result: the empty panel. Reviewers cannot repeat in a panel.

Constraints

  • 0 <= n <= 50; 0 <= k <= 50. All final counts fit exactly in JSON Number.
  • Intermediate factorials do not fit in a safe Number; use exact integer arithmetic or a bounded recurrence.

Examples

Example 1

{
  "k": 2,
  "n": 5
}

Returns

10

Example 2

{
  "k": 4,
  "n": 3
}

Returns

0

Required complexity

O(min(k,n-k)) exact-integer steps and O(1) accumulators; return immediately when k > n

What this task practices

Count Review Panels is a coding (algo) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as medium difficulty. It focuses on Technical Reasoning, Testing, Validation. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.