As reported: Zscaler Summer 2026 SDE intern online assessment (HackerRank, November 2025), section 1 (Python only): a firm has
2nemployees, employeeihas efficiencyi. Split them intonteams of two. A type-1 task's team efficiency is the minimum of its two members; a type-2 task's is the maximum. The firm picksxteams (0 ≤ x ≤ n) for type 1 and the othern − xfor type 2. Count the values ofxfor which the target listtotalEfficiencycan be achieved; for eachxthe pairing can be chosen freely.
There are 2n employees with efficiencies 1, 2, …, 2n. You are given n distinct values totalEfficiency in [1, 2n]. For a chosen x, you must pair up all 2n employees into n teams, then choose x teams that report their minimum member and n − x teams that report their maximum. The goal is that the set of reported values is exactly totalEfficiency.
Return how many values of x in [0, n] make this possible.
Example 1
n = 1, totalEfficiency = [1]
Only team {1, 2}. x = 1: min = 1 ✓. x = 0: max = 2 ✗.
Output: 1
Example 2
n = 5, totalEfficiency = [1, 4, 5, 9, 10]
x = 1: (1, 6) min, (2, 4) max, (3, 5) max, (7, 9) max, (8, 10) max
x = 2: (1, 6) min, (4, 7) min, (2, 5) max, (3, 9) max, (8, 10) max
x = 3: (1, 6) min, (4, 7) min, (5, 8) min, (2, 9) max, (3, 10) max
Output: 3
Example 3
n = 2, totalEfficiency = [3, 4]
Partners are 1 and 2, both smaller: only x = 0 works.
Output: 1
Constraints (the post gives none; these are ours): 1 ≤ n ≤ 10^5; totalEfficiency holds n distinct integers in [1, 2n], in any order.
Code runner format: two JSON values, one per line: n and totalEfficiency. Implement countValidX(n, totalEfficiency).