1800. Maximum Ascending Subarray Sum Easy
1/**
2 * [1800] Maximum Ascending Subarray Sum
3 *
4 * Given an array of positive integers nums, return the maximum possible sum of an ascending subarray in nums.
5 * A subarray is defined as a contiguous sequence of numbers in an array.
6 * A subarray [numsl, numsl+1, ..., numsr-1, numsr] is ascending if for all i where l <= i < r, numsi < numsi+1. Note that a subarray of size 1 is ascending.
7 *
8 * Example 1:
9 *
10 * Input: nums = [10,20,30,5,10,50]
11 * Output: 65
12 * Explanation: [5,10,50] is the ascending subarray with the maximum sum of 65.
13 *
14 * Example 2:
15 *
16 * Input: nums = [10,20,30,40,50]
17 * Output: 150
18 * Explanation: [10,20,30,40,50] is the ascending subarray with the maximum sum of 150.
19 *
20 * Example 3:
21 *
22 * Input: nums = [12,17,15,13,10,11,12]
23 * Output: 33
24 * Explanation: [10,11,12] is the ascending subarray with the maximum sum of 33.
25 *
26 *
27 * Constraints:
28 *
29 * 1 <= nums.length <= 100
30 * 1 <= nums[i] <= 100
31 *
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/maximum-ascending-subarray-sum/
36// discuss: https://leetcode.com/problems/maximum-ascending-subarray-sum/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41 pub fn max_ascending_sum(nums: Vec<i32>) -> i32 {
42 0
43 }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn test_1800() {
54 }
55}
56
Back
© 2025 bowen.ge All Rights Reserved.