Tap here to switch tabs
Problem
Submissions

Problem: Maximum Score Of Spliced Array

Maximum Score Of Spliced Array lets you swap one contiguous segment between two equal-length integer arrays, or skip the swap, and asks for the largest possible sum of either array.

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

Maximum Score Of Spliced Array lets you swap one contiguous segment between two equal-length integer arrays, or skip the swap, and asks for the largest possible sum of either array.

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