java.lang.Object
g1701_1800.s1800_maximum_ascending_subarray_sum.Solution

public class Solution extends Object
1800 - Maximum Ascending Subarray Sum.<p>Easy</p> <p>Given an array of positive integers <code>nums</code>, return the <em>maximum possible sum of an <strong>ascending</strong> subarray in</em> <code>nums</code>.</p> <p>A subarray is defined as a contiguous sequence of numbers in an array.</p> <p>A subarray <code>[nums<sub>l</sub>, nums<sub>l+1</sub>, &hellip;, nums<sub>r-1</sub>, nums<sub>r</sub>]</code> is <strong>ascending</strong> if for all <code>i</code> where <code>l <= i < r</code>, <code>nums<sub>i</sub> < nums<sub>i+1</sub></code>. Note that a subarray of size <code>1</code> is <strong>ascending</strong>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> nums = [10,20,30,5,10,50]</p> <p><strong>Output:</strong> 65</p> <p><strong>Explanation:</strong> [5,10,50] is the ascending subarray with the maximum sum of 65.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> nums = [10,20,30,40,50]</p> <p><strong>Output:</strong> 150</p> <p><strong>Explanation:</strong> [10,20,30,40,50] is the ascending subarray with the maximum sum of 150.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> nums = [12,17,15,13,10,11,12]</p> <p><strong>Output:</strong> 33</p> <p><strong>Explanation:</strong> [10,11,12] is the ascending subarray with the maximum sum of 33.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= nums.length <= 100</code></li> <li><code>1 <= nums[i] <= 100</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • maxAscendingSum

      public int maxAscendingSum(int[] nums)