You are given two integer arrays lane1 and lane2 of equal length, representing the number of coins available at each mile along a two lane freeway.
Mario drives along a contiguous stretch of the freeway covering at least
He starts driving in lane1.
He may switch to lane2 at most once.
After driving in lane2, he may switch back to lane1 at most once.
He cannot switch back to lane2 again.
In other words, his journey consists of up to three consecutive segments: an initial segment in lane1, a middle segment in lane2, and a final segment in lane1. Any of these segments may be empty, but the total distance driven across all chosen segments must be at least
Return the maximum total number of coins Mario can collect.
Constraints:
lane1.length lane2.length
lane1[i], lane2[i]
You are given two integer arrays lane1 and lane2 of equal length, representing the number of coins available at each mile along a two lane freeway.
Mario drives along a contiguous stretch of the freeway covering at least
He starts driving in lane1.
He may switch to lane2 at most once.
After driving in lane2, he may switch back to lane1 at most once.
He cannot switch back to lane2 again.
In other words, his journey consists of up to three consecutive segments: an initial segment in lane1, a middle segment in lane2, and a final segment in lane1. Any of these segments may be empty, but the total distance driven across all chosen segments must be at least
Return the maximum total number of coins Mario can collect.
Constraints:
lane1.length lane2.length
lane1[i], lane2[i]