hard 0 views

Trionic Array II

You are given an integer array nums of length n.

You are given an integer array nums of length n.

A trionic subarray is a contiguous subarray nums[l...r] (with 0 <= l < r < n) for which there exist indices l < p < q < r such that:

Return the maximum sum of any trionic subarray in nums.

Trionic Array II diagram

Example 1

Input: nums = [0,-2,-1,-3,0,2,-1]

Output: -4

Explanation: Pick l = 1 , p = 2 , q = 3 , r = 5 :

Example 2

Input: nums = [1,4,2,7]

Output: 14

Explanation: Pick l = 0 , p = 1 , q = 2 , r = 3 :

Constraints

  • 4 <= n = nums.length <= 10^5
  • -10^9 <= nums[i] <= 10^9
  • It is guaranteed that at least one trionic subarray exists.

Hints

Companies

No companies reported yet.

Discussion

Sign in to join the discussion.

Loading discussion...

Test results

No test cases yet.