Practice Get the Maximum Score
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Traverse either sorted, distinct-valued array from its first element toward its last. At a value appearing in both nums1 and nums2, you may switch to the matching position in the other array and continue forward. Count a shared value only once when switching. Return the greatest possible sum along a complete path, modulo 10^9 + 7.
Source: Get the Maximum Score on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums1 = [2,4,5,8,10], nums2 = [4,6,8,9]
Output
30
# Example 2
Input
nums1 = [1,3,5,7,9], nums2 = [3,5,100]
Output
109
# Example 3
Input
nums1 = [1,2,3,4,5], nums2 = [6,7,8,9,10]
Output
40
Constraints
1 <= nums1.length, nums2.length <= 10^5
1 <= nums1[i], nums2[i] <= 10^7
nums1 and nums2 are strictly increasing.
Related LeetCode Problems
Practice more problems similar to Get the Maximum Score.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.