Algorithms
Hard
2945
3211
Find Maximum Non-decreasing Array Length
find-maximum-non-decreasing-array-length
"""
You are given a 0-indexed integer array nums.
You can perform any number of operations, where each operation involves selecting a subarray of the array and replacing it with the sum of its elements. For example, if the given array is [1,3,5,6] and you select subarray [3,5] the array will convert to [1,8,6].
Return the maximum length of a non-decreasing array that can be made after applying operations.
A subarray is a contiguous non-empty sequence of elements within an array.

Example 1:

Input: nums = [5,2,2]
Output: 1
Explanation: This array with length 3 is not non-decreasing.
We have two ways to make the array length two.
First, choosing subarray [2,2] converts the array to [5,4].
Second, choosing subarray [5,2] converts the array to [7,2].
In these two ways the array is not non-decreasing.
And if we choose subarray [5,2,2] and replace it with [9] it becomes non-decreasing. 
So the answer is 1.

Example 2:

Input: nums = [1,2,3,4]
Output: 4
Explanation: The array is non-decreasing. So the answer is 4.

Example 3:

Input: nums = [4,3,2,6]
Output: 3
Explanation: Replacing [3,2] with [5] converts the given array to [4,5,6] that is non-decreasing.
Because the given array is not non-decreasing, the maximum possible answer is 3.

Constraints:

1 <= nums.length <= 105
1 <= nums[i] <= 105
"""
class Solution:
    def findMaximumLength(self, nums: List[int]) -> int:
        
You are given a 0-indexed integer array nums.
You can perform any number of operations, where each operation involves selecting a subarray of the array and replacing it with the sum of its elements. For example, if the given array is [1,3,5,6] and you select subarray [3,5] the array will convert to [1,8,6].
Return the maximum length of a non-decreasing array that can be made after applying operations.
A subarray is a contiguous non-empty sequence of elements within an array.

Example 1:

Input: nums = [5,2,2]
Output: 1
Explanation: This array with length 3 is not non-decreasing.
We have two ways to make the array length two.
First, choosing subarray [2,2] converts the array to [5,4].
Second, choosing subarray [5,2] converts the array to [7,2].
In these two ways the array is not non-decreasing.
And if we choose subarray [5,2,2] and replace it with [9] it becomes non-decreasing. 
So the answer is 1.

Example 2:

Input: nums = [1,2,3,4]
Output: 4
Explanation: The array is non-decreasing. So the answer is 4.

Example 3:

Input: nums = [4,3,2,6]
Output: 3
Explanation: Replacing [3,2] with [5] converts the given array to [4,5,6] that is non-decreasing.
Because the given array is not non-decreasing, the maximum possible answer is 3.

Constraints:

1 <= nums.length <= 105
1 <= nums[i] <= 105


Please complete the code below to solve above prblem:
```python
class Solution:
    def findMaximumLength(self, nums: List[int]) -> int:
        
```

my_solution = Solution()

test_input = { "nums": [5,2,2] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [1,2,3,4] }
assert my_solution.findMaximumLength(**test_input) == 4

test_input = { "nums": [4,3,2,6] }
assert my_solution.findMaximumLength(**test_input) == 3

test_input = { "nums": [32] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [38] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [60] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [79] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [85] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [170] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [198] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [220] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [318] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [350] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [381] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [413] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [426] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [429] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [431] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [445] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [488] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [492] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [497] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [515] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [582] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [589] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [620] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [632] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [703] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [748] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [776] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [977] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [986] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [990] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [29,859] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [48,612] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [76,837] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [103,341] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [171,323] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [248,719] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [253,61] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [274,467] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [351,665] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [372,382] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [404,409] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [455,40] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [472,843] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [504,838] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [549,747] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [570,810] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [621,809] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [643,802] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [689,192] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [709,481] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [742,67] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [745,725] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [773,877] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [776,962] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [791,434] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [824,783] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [840,388] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [876,264] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [940,694] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [959,372] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [981,998] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [41,340,784] }
assert my_solution.findMaximumLength(**test_input) == 3

test_input = { "nums": [103,652,579] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [116,635,966] }
assert my_solution.findMaximumLength(**test_input) == 3

test_input = { "nums": [137,32,745] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [247,173,316] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [276,315,947] }
assert my_solution.findMaximumLength(**test_input) == 3

test_input = { "nums": [278,754,912] }
assert my_solution.findMaximumLength(**test_input) == 3

test_input = { "nums": [314,882,708] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [371,101,367] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [402,305,990] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [403,553,697] }
assert my_solution.findMaximumLength(**test_input) == 3

test_input = { "nums": [431,780,315] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [479,322,44] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [512,234,679] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [513,847,778] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [525,177,936] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [588,42,18] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [646,174,827] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [680,242,726] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [769,131,241] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [780,591,213] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [783,23,848] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [787,201,30] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [791,470,87] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [797,181,492] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [868,4,455] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [881,306,316] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [886,116,68] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [893,531,805] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [926,641,145] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [964,624,279] }
assert my_solution.findMaximumLength(**test_input) == 1

test_input = { "nums": [987,694,396] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [38,986,134,156] }
assert my_solution.findMaximumLength(**test_input) == 2

test_input = { "nums": [43,236,417,521] }
assert my_solution.findMaximumLength(**test_input) == 4

test_input = { "nums": [58,890,892,52] }
assert my_solution.findMaximumLength(**test_input) == 3

test_input = { "nums": [81,738,403,654] }
assert my_solution.findMaximumLength(**test_input) == 3