[Leetcode] Maximum Sum of 3 non-overlapping subarrays three phenanthrene overlapping sub-arrays of the most Yamato

Source: Internet
Author: User

In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum.

Each subarray would be k is of size, and we want to maximize the sum of all 3*k entries.

Return The result as a list of indices representing the starting position of each interval (0-indexed). If There is multiple answers, return the lexicographically smallest one.

Example:

Input: [1,2,1,2,6,7,5,1], 2Output: [0, 3, 5]explanation:subarrays [1, 2], [2, 6], [7, 5] correspond to the starting Indic Es [0, 3, 5]. We could has also taken [2, 1], but a answer of [1, 3, 5] would be lexicographically larger.

Note:

    • nums.lengthwould be between 1 and 20000.
    • nums[i]would be between 1 and 65535.
    • k'll is between 1 and floor (NUMS.LENGTH/3).

S

[Leetcode] Maximum Sum of 3 non-overlapping subarrays three phenanthrene overlapping sub-arrays of the most Yamato

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.