Maximum Subsequence Score
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 two integer arrays nums1 and nums2 of equal length n and an integer k. Choose exactly k distinct indices. The score of the choice is (the sum of nums1 over the chosen indices) multiplied by (the minimum of nums2 over the chosen indices).
Return the maximum possible score. The result can exceed 32-bit range.
Aim for O(n log n) time.
Examples
Constraints
- 1 <= k <= n <= 10^5
- `nums1.length == nums2.length == n`
- 0 <= nums1[i], nums2[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.