Tap here to switch tabs
Problem
Submissions

Problem: Maximum Score Of Spliced Array

med
30 min
Try to solve the Maximum Score Of Spliced Array problem.

Statement

You are given two integer arrays nums1 and nums2, each of length n.

You may choose two indices left and right such that 0≤0 \leq left ≤\leq right << n, and swap the elements between nums1 and nums2 from index left to index right inclusive. You can perform this operation at most once, or choose not to perform any swap.

The score is defined as the maximum of the sum of elements in nums1 and the sum of elements in nums2.

Return the maximum possible score you can achieve.

Constraints:

  • n ==== nums1.length ==== nums2.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 1≤1 \leq nums1[i], nums2[i] ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Score Of Spliced Array

med
30 min
Try to solve the Maximum Score Of Spliced Array problem.

Statement

You are given two integer arrays nums1 and nums2, each of length n.

You may choose two indices left and right such that 0≤0 \leq left ≤\leq right << n, and swap the elements between nums1 and nums2 from index left to index right inclusive. You can perform this operation at most once, or choose not to perform any swap.

The score is defined as the maximum of the sum of elements in nums1 and the sum of elements in nums2.

Return the maximum possible score you can achieve.

Constraints:

  • n ==== nums1.length ==== nums2.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 1≤1 \leq nums1[i], nums2[i] ≤104\leq 10^4