N-Repeated Element in Size 2N Array
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given an integer array nums of even length 2 * n. The array holds exactly n + 1
distinct values: one of them appears exactly n times, and each of the other n values appears
exactly once.
Return the value that appears n times. The input is guaranteed to have this shape, so the answer
always exists and is unique.
Aim for O(n) time; an O(1)-extra-space solution is possible.
Examples
Constraints
- 2 <= n <= 5000
- nums.length == 2 * n
- 0 <= nums[i] <= 10^4
- `nums` contains exactly `n + 1` distinct values, one of which appears exactly `n` times
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.