Search
⌘K

Leetcode 2945. Find Maximum Non-decreasing Array Length

Given a positive-integer array where you may replace any contiguous subarray by its sum, find the maximum number of contiguous segments you can partition the array into so that the sequence of segment sums is non-decreasing. With n up to 1e5, this reduces to greedily merging adjacent elements/segments until the sequence of segment sums becomes non-decreasing.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.