4Sum II
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 four integer arrays nums1, nums2, nums3, and nums4, all of the same length n.
Count the index tuples (i, j, k, l) with 0 <= i, j, k, l < n such that nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0. Tuples are distinguished by their indices, so equal values at different positions count separately.
Aim for O(n^2) time.
Examples
Constraints
- n == nums1.length == nums2.length == nums3.length == nums4.length
- 1 <= n <= 200
- -2^28 <= nums[i] <= 2^28
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.