Array of Doubled Pairs
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 arr of **even** length. Decide whether its elements can be split into arr.length / 2 pairs where one element of each pair is exactly **twice** the other.
Equivalently, return true if arr can be reordered so that arr[2i + 1] == 2 * arr[2i] for every 0 <= i < arr.length / 2, and false otherwise. Values may be negative or zero. Aim for O(n log n) time.
Examples
Constraints
- 2 <= arr.length <= 3 * 10^4
- arr.length is even
- -10^5 <= arr[i] <= 10^5
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.