Skip to content

Commit 9dda2cd

Browse files
committed
update: 添加问题“1732.找到最高海拔”的代码(并更新其题解) (#1646)
1732: AC.cpp+go+java+py+rust (#1645) + en+jp + accumulation.Phishing cpp - AC,100.00%,57.30% go - AC,100.00%,58.95% java - AC,100.00%,83.62% python - AC,100.00%,85.43% rust - AC,100.00%,50.00% 3689: 修改入参的题解注释 #1626 (comment) Signed-off-by: LetMeFly666 <Tisfy@qq.com>
1 parent cadb513 commit 9dda2cd

13 files changed

Lines changed: 182 additions & 43 deletions

.commitmsg

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
1732: AC.cpp+go+java+py+rust (#1645) + en+jp + accumulation.Phishing
2+
3+
cpp - AC,100.00%,57.30%
4+
go - AC,100.00%,58.95%
5+
java - AC,100.00%,83.62%
6+
python - AC,100.00%,85.43%
7+
rust - AC,100.00%,50.00%
8+
9+
3689: 修改入参的题解注释
10+
https://github.com/LetMeFly666/LeetCode/pull/1626#discussion_r3382012262
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2026-06-19 10:15:51
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2026-06-19 10:16:25
6+
*/
7+
#ifdef _DEBUG
8+
#include "_[1,2]toVector.h"
9+
#endif
10+
11+
class Solution {
12+
public:
13+
int largestAltitude(vector<int>& gain) {
14+
int ans = 0, now = 0;
15+
for (int t : gain) {
16+
now += t;
17+
ans = max(ans, now);
18+
}
19+
return ans;
20+
}
21+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2026-06-19 10:15:51
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2026-06-19 10:17:13
6+
*/
7+
package main
8+
9+
func largestAltitude(gain []int) (ans int) {
10+
now := 0
11+
for _, t := range gain {
12+
now += t
13+
ans = max(ans, now)
14+
}
15+
return
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2026-06-19 10:15:51
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2026-06-19 10:18:18
6+
*/
7+
class Solution {
8+
public int largestAltitude(int[] gain) {
9+
int ans = 0, now = 0;
10+
for (int t : gain) {
11+
now += t;
12+
ans = Math.max(ans, now);
13+
}
14+
return ans;
15+
}
16+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'''
2+
Author: LetMeFly
3+
Date: 2026-06-19 10:15:51
4+
LastEditors: LetMeFly.xyz
5+
LastEditTime: 2026-06-19 10:19:06
6+
'''
7+
from typing import List
8+
9+
class Solution:
10+
def largestAltitude(self, gain: List[int]) -> int:
11+
ans = now = 0
12+
for t in gain:
13+
now += t
14+
ans = max(ans, now)
15+
return ans
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* @Author: LetMeFly
3+
* @Date: 2026-06-19 10:15:51
4+
* @LastEditors: LetMeFly.xyz
5+
* @LastEditTime: 2026-06-19 10:19:43
6+
*/
7+
impl Solution {
8+
pub fn largest_altitude(gain: Vec<i32>) -> i32 {
9+
let mut ans = 0;
10+
let mut now = 0;
11+
for t in gain.iter() {
12+
now += t;
13+
ans = ans.max(now);
14+
}
15+
ans
16+
}
17+
}

Codes/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
pub struct Solution;
88

9-
include!("2144-minimum-cost-of-buying-candies-with-discount.rs"); // 这个fileName是会被脚本替换掉的
9+
include!("1732-find-the-highest-altitude_20260619.rs"); // 这个fileName是会被脚本替换掉的
1010

1111
#[derive(Debug, PartialEq, Eq)]
1212
pub struct TreeNode {

Solutions/LeetCode 1732.找到最高海拔.md

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
title: 1732.找到最高海拔
2+
title: 1732.找到最高海拔:模拟
33
date: 2022-11-19 08:33:19
44
tags: [题解, LeetCode, 简单, 数组, 前缀和, 模拟]
55
categories: [题解, LeetCode]
66
---
77

8-
# 【LetMeFly】1732.找到最高海拔
8+
# 【LetMeFly】1732.找到最高海拔:模拟
99

1010
力扣题目链接:[https://leetcode.cn/problems/find-the-highest-altitude/](https://leetcode.cn/problems/find-the-highest-altitude/)
1111

@@ -59,6 +59,9 @@ categories: [题解, LeetCode]
5959
#### C++
6060

6161
```cpp
62+
/*
63+
* @LastEditTime: 2022-11-19 08:30:56
64+
*/
6265
class Solution {
6366
public:
6467
int largestAltitude(vector<int>& gain) {
@@ -73,5 +76,78 @@ public:
7376
};
7477
```
7578
79+
#### Python
80+
81+
```python
82+
'''
83+
LastEditTime: 2026-06-19 10:19:06
84+
'''
85+
from typing import List
86+
87+
class Solution:
88+
def largestAltitude(self, gain: List[int]) -> int:
89+
ans = now = 0
90+
for t in gain:
91+
now += t
92+
ans = max(ans, now)
93+
return ans
94+
95+
```
96+
97+
#### Java
98+
99+
```java
100+
/*
101+
* @LastEditTime: 2026-06-19 10:18:18
102+
*/
103+
class Solution {
104+
public int largestAltitude(int[] gain) {
105+
int ans = 0, now = 0;
106+
for (int t : gain) {
107+
now += t;
108+
ans = Math.max(ans, now);
109+
}
110+
return ans;
111+
}
112+
}
113+
```
114+
115+
#### Go
116+
117+
```go
118+
/*
119+
* @LastEditTime: 2026-06-19 10:17:13
120+
*/
121+
package main
122+
123+
func largestAltitude(gain []int) (ans int) {
124+
now := 0
125+
for _, t := range gain {
126+
now += t
127+
ans = max(ans, now)
128+
}
129+
return
130+
}
131+
```
132+
133+
#### Rust
134+
135+
```rust
136+
/*
137+
* @LastEditTime: 2026-06-19 10:19:43
138+
*/
139+
impl Solution {
140+
pub fn largest_altitude(gain: Vec<i32>) -> i32 {
141+
let mut ans = 0;
142+
let mut now = 0;
143+
for t in gain.iter() {
144+
now += t;
145+
ans = ans.max(now);
146+
}
147+
ans
148+
}
149+
}
150+
```
151+
76152
> 同步发文于CSDN,原创不易,转载请附上[原文链接](https://blog.letmefly.xyz/2022/11/19/LeetCode%201732.%E6%89%BE%E5%88%B0%E6%9C%80%E9%AB%98%E6%B5%B7%E6%8B%94/)哦~
77153
> Tisfy:[https://letmefly.blog.csdn.net/article/details/127932334](https://letmefly.blog.csdn.net/article/details/127932334)

Solutions/LeetCode 3689.最大子数组总值I.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ categories: [题解, LeetCode]
9292
typedef long long ll;
9393
class Solution {
9494
public:
95-
ll maxTotalValue(vector<int>& nums, ll k) {
95+
ll maxTotalValue(vector<int>& nums, ll k) { // 注意这里有个比较trick的方法,直接在入参把k改为了long long
9696
int m = nums[0], M = m;
9797
for (int t : nums) {
9898
m = min(m, t);

Solutions/Other-Accumulation-SomeTips.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,10 @@ fn foo(x: u32)
17991799

18001800
用户一升级版本,代码就炸了。
18011801

1802+
### Phishing
1803+
1804+
网络钓鱼,伪装成可信实体诱骗用户主动交出敏感信息或执行危险操作。
1805+
18021806
# End
18031807

18041808
> 同步发文于CSDN,原创不易,转载请附上[原文链接](https://blog.letmefly.xyz/2023/02/21/Other-Accumulation-SomeTips)哦~

0 commit comments

Comments
 (0)