Skip to content

Commit 1373b2f

Browse files
committed
一刷1480
1 parent f52eb46 commit 1373b2f

File tree

6 files changed

+39
-13
lines changed

6 files changed

+39
-13
lines changed

README.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10386,12 +10386,12 @@ TIP: **公众号的微信号是: `jikerizhi`**。__因为众所周知的原因
1038610386
//|Hard
1038710387
//|
1038810388

10389-
//|{counter:codes}
10390-
//|{leetcode_base_url}/running-sum-of-1d-array/[1480. Running Sum of 1d Array^]
10391-
//|{source_base_url}/_1480_RunningSumOf1DArray.java[Java]
10392-
//|{doc_base_url}/1480-running-sum-of-1d-array.adoc[题解]
10393-
//|Easy
10394-
//|
10389+
|{counter:codes}
10390+
|{leetcode_base_url}/running-sum-of-1d-array/[1480. Running Sum of 1d Array^]
10391+
|{source_base_url}/_1480_RunningSumOf1DArray.java[Java]
10392+
|{doc_base_url}/1480-running-sum-of-1d-array.adoc[题解]
10393+
|Easy
10394+
|
1039510395

1039610396
//|{counter:codes}
1039710397
//|{leetcode_base_url}/least-number-of-unique-integers-after-k-removals/[1481. Least Number of Unique Integers after K Removals^]

docs/1480-running-sum-of-1d-array.adoc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Given an array `nums`. We define a running sum of an array as `runningSum[i] = s
88
Return the running sum of `nums`.
99

1010

11-
<strong class="example">Example 1:*
11+
*Example 1:*
1212

1313
[subs="verbatim,quotes"]
1414
----
@@ -17,7 +17,7 @@ Return the running sum of `nums`.
1717
*Explanation:* Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].
1818
----
1919

20-
<strong class="example">Example 2:*
20+
*Example 2:*
2121

2222
[subs="verbatim,quotes"]
2323
----
@@ -26,7 +26,7 @@ Return the running sum of `nums`.
2626
*Explanation:* Running sum is obtained as follows: [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1].
2727
----
2828

29-
<strong class="example">Example 3:*
29+
*Example 3:*
3030

3131
[subs="verbatim,quotes"]
3232
----
@@ -39,14 +39,14 @@ Return the running sum of `nums`.
3939
*Constraints:*
4040

4141

42-
* `1 <= nums.length <= 1000`
43-
* `-10^6 <= nums[i] <= 10^6`
44-
42+
* `1 \<= nums.length \<= 1000`
43+
* `-10^6 \<= nums[i] \<= 10^6`
4544

4645

4746

4847
== 思路分析
4948

49+
image::images/1480-01.gif[{image_attr}]
5050

5151
[[src-1480]]
5252
[tabs]
@@ -73,4 +73,6 @@ include::{sourcedir}/_1480_RunningSumOf1DArray.java[tag=answer]
7373

7474
== 参考资料
7575

76+
. https://leetcode.cn/problems/running-sum-of-1d-array/solutions/1645947/by-jyd-hz70/?envType=study-plan-v2&envId=selected-coding-interview[1480. 一维数组的动态和 -动态规划,清晰图解^]
77+
7678

docs/images/1480-01.gif

7.29 MB
Loading

docs/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3034,7 +3034,7 @@ include::1109-corporate-flight-bookings.adoc[leveloffset=+1]
30343034

30353035
// include::1479-sales-by-day-of-the-week.adoc[leveloffset=+1]
30363036

3037-
// include::1480-running-sum-of-1d-array.adoc[leveloffset=+1]
3037+
include::1480-running-sum-of-1d-array.adoc[leveloffset=+1]
30383038

30393039
// include::1481-least-number-of-unique-integers-after-k-removals.adoc[leveloffset=+1]
30403040

logbook/202406.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,11 @@
515515
|{doc_base_url}/0226-invert-binary-tree.adoc[题解]
516516
|分治
517517

518+
|{counter:codes}
519+
|{leetcode_base_url}/running-sum-of-1d-array/[1480. Running Sum of 1d Array^]
520+
|{doc_base_url}/1480-running-sum-of-1d-array.adoc[题解]
521+
|动态规划入门
522+
518523
|===
519524

520525
截止目前,本轮练习一共完成 {codes} 道题。
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.diguage.algo.leetcode;
2+
3+
public class _1480_RunningSumOf1DArray {
4+
// tag::answer[]
5+
6+
/**
7+
* @author D瓜哥 · https://www.diguage.com
8+
* @since 2024-09-13 23:14:43
9+
*/
10+
public int[] runningSum(int[] nums) {
11+
int[] dp = new int[nums.length];
12+
dp[0] = nums[0];
13+
for (int i = 1; i < nums.length; i++) {
14+
dp[i] = nums[i] + dp[i - 1];
15+
}
16+
return dp;
17+
}
18+
// end::answer[]
19+
}

0 commit comments

Comments
 (0)