# Problem Statement Given an array of positive integers `nums`, return the _maximum possible sum of an **ascending** subarray in_ `nums`. A subarray is defined as a contiguous sequence of numbers in an array. A subarray `[numsl, numsl+1, ..., numsr-1, numsr]` is **ascending** if for all `i` where `l <= i < r`, `nums`$_{i}$ < `nums`$_{i+1}
. Note that a subarray of size `1` is **ascending**. ## Constraints - `1 <= nums.length <= 100` - `1 <= nums[i] <= 100` # Solution We can iterate through the list, while keeping track of the running sum. If ascendancy breaks, we set the number it broke on as the new start and continue iterating. ```python mx, prev, total = nums[0], nums[0], nums[0] for num in nums[1:]: total = total * int(num > prev) + num mx = max(mx, total) prev = num return mx ``` Time Complexity: O$(n)$ | Space Complexity: O$(1)$