We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 91f417a commit 02e98dcCopy full SHA for 02e98dc
src/main.rs
@@ -1,5 +1,5 @@
1
-mod p2948;
+mod p1800;
2
3
pub fn main() {
4
- p2948::run();
+ p1800::run();
5
}
src/p1800.rs
@@ -0,0 +1,29 @@
+pub fn run() {
+ for i in [
+
+ ] {
+ println!("{}", max_ascending_sum(i));
6
+ }
7
+}
8
9
+pub fn max_ascending_sum(nums: Vec<i32>) -> i32 {
10
+ let mut nums = nums.into_iter();
11
+ let mut previous = nums.next().unwrap();
12
13
+ let mut highest = previous;
14
+ let mut current = previous;
15
16
+ while let Some(n) = nums.next() {
17
+ if previous >= n {
18
+ current = 0;
19
20
21
+ current += n;
22
23
+ highest = highest.max(current);
24
25
+ previous = n;
26
27
28
+ highest
29
0 commit comments