Problem
You get two integer arrays nums1 and nums2 of the same length n, and a positive integer k. Choose k different indexes from 0 to n - 1.
The score of a choice is the sum of the chosen items in nums1, multiplied by the minimum of the chosen items in nums2. For example, for the indexes i, j and l, the score is (nums1[i] + nums1[j] + nums1[l]) * min(nums2[i], nums2[j], nums2[l]).
Return the largest possible score.
Example 1
- Input:
- nums1 = [2,5,1,4], nums2 = [3,1,6,2], k = 2
- Output:
- 12
- Explanation:
- Choose the indexes 0 and 3. The score is
(2 + 4) * min(3, 2) = 12. No other pair of indexes gives more.
Example 2
- Input:
- nums1 = [3,3,3], nums2 = [5,2,9], k = 1
- Output:
- 27
- Explanation:
- Choose index 2. The score is
3 * 9 = 27.
Example 3
- Input:
- nums1 = [1,2,3], nums2 = [4,5,6], k = 3
- Output:
- 24
Constraints
- n == nums1.length == nums2.length
- 1 <= n <= 10^5
- 0 <= nums1[i], nums2[j] <= 10^5
- 1 <= k <= n
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Find and Count Maximum-Score Grid Paths
Coding · Dynamic Programming · Grids & Matrices
- Find the Maximum Divisibility Score
Coding
- Find the Maximum Factor Score of Array
Coding
- Find the Maximum Length of a Good Subsequence I
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
Google
Leetcode 2542. Maximum Subsequence Score
Reported Oct 22, 2024 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View source