3Sum Smaller
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
Given an integer array nums and an integer target, count the index triplets (i, j, k) with
0 <= i < j < k < nums.length such that nums[i] + nums[j] + nums[k] < target.
Triplets are counted by position, so equal values at different indices form different triplets. Return the count.
An O(n^2) solution is expected.
Examples
Constraints
- 0 <= nums.length <= 3500
- -100 <= nums[i] <= 100
- -100 <= target <= 100
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.