Maximum Score Of Spliced Array
You have two 0-indexed integer arrays nums1 and nums2, both of length n. You can select two integers, left and right, where 0 ≤ left ≤ right < n, and interchange the subarray nums1[left...right] with the subarray nums2[left...right].
For instance, if nums1 = [1,2,3,4,5] and nums2 = [11,12,13,14,15], and you select left = 1 and right = 2, nums1 becomes [1,12,13,4,5] and nums2 becomes [11,2,3,14,15].
You're allowed to perform this operation once or not do anything at all.
The score of the arrays is determined by the maximum of sum(nums1) and sum(nums2), where sum(arr) denotes the sum of all elements in the array arr.
Your task is to find and print the maximum possible score.
I want to discuss a solution
Help me solve this
Give more examples
What's wrong with my code?
How to use 'for loop' in javascript?