Skip to content

Commit 23654b8

Browse files
author
lucifer
committed
fix: remove useless comment
1 parent 5aa4a19 commit 23654b8

File tree

2 files changed

+9
-107
lines changed

2 files changed

+9
-107
lines changed

problems/494.target-sum.md

Lines changed: 9 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
2-
31
## 题目地址
2+
43
https://leetcode.com/problems/target-sum/description/
54

65
## 题目描述
@@ -11,9 +10,9 @@ You are given a list of non-negative integers, a1, a2, ..., an, and a target, S.
1110
Find out how many ways to assign symbols to make sum of integers equal to target S.
1211
1312
Example 1:
14-
Input: nums is [1, 1, 1, 1, 1], S is 3.
13+
Input: nums is [1, 1, 1, 1, 1], S is 3.
1514
Output: 5
16-
Explanation:
15+
Explanation:
1716
1817
-1+1+1+1+1 = 3
1918
+1-1+1+1+1 = 3
@@ -28,9 +27,10 @@ The sum of elements in the given array will not exceed 1000.
2827
Your output answer is guaranteed to be fitted in a 32-bit integer.
2928
3029
```
30+
3131
## 思路
3232

33-
题目是给定一个数组,让你在数字前面添加 `+`或者`-`使其和等于target.
33+
题目是给定一个数组,让你在数字前面添加 `+`或者`-`使其和等于 target.
3434

3535
![494.target-sum](../assets/problems/494.target-sum.png)
3636

@@ -48,62 +48,22 @@ Your output answer is guaranteed to be fitted in a 32-bit integer.
4848

4949
![494.target-sum-3](../assets/problems/494.target-sum-3.png)
5050

51-
因此问题转化为,求解`sumCount(nums, target)`,即nums数组中能够组成
52-
target的总数一共有多少种,这是一道我们之前做过的题目,使用动态规划可以解决。
51+
因此问题转化为,求解`sumCount(nums, target)`,即 nums 数组中能够组成
52+
target 的总数一共有多少种,这是一道我们之前做过的题目,使用动态规划可以解决。
5353

5454
## 关键点解析
5555

5656
- 对元素进行分组,分组的依据是符号, 是`+` 或者 `-`
5757
- 通过数学公式推导可以简化我们的求解过程,这需要一点`数学知识和数学意识`
5858

5959
## 代码
60+
6061
```js
6162
/*
6263
* @lc app=leetcode id=494 lang=javascript
6364
*
6465
* [494] Target Sum
6566
*
66-
* https://leetcode.com/problems/target-sum/description/
67-
*
68-
* algorithms
69-
* Medium (44.86%)
70-
* Total Accepted: 89.3K
71-
* Total Submissions: 198.5K
72-
* Testcase Example: '[1,1,1,1,1]\n3'
73-
*
74-
*
75-
* You are given a list of non-negative integers, a1, a2, ..., an, and a
76-
* target, S. Now you have 2 symbols + and -. For each integer, you should
77-
* choose one from + and - as its new symbol.
78-
* ⁠
79-
*
80-
* Find out how many ways to assign symbols to make sum of integers equal to
81-
* target S.
82-
*
83-
*
84-
* Example 1:
85-
*
86-
* Input: nums is [1, 1, 1, 1, 1], S is 3.
87-
* Output: 5
88-
* Explanation:
89-
*
90-
* -1+1+1+1+1 = 3
91-
* +1-1+1+1+1 = 3
92-
* +1+1-1+1+1 = 3
93-
* +1+1+1-1+1 = 3
94-
* +1+1+1+1-1 = 3
95-
*
96-
* There are 5 ways to assign symbols to make the sum of nums be target 3.
97-
*
98-
*
99-
*
100-
* Note:
101-
*
102-
* The length of the given array is positive and will not exceed 20.
103-
* The sum of elements in the given array will not exceed 1000.
104-
* Your output answer is guaranteed to be fitted in a 32-bit integer.
105-
*
106-
*
10767
*/
10868
// 这个是我们熟悉的问题了
10969
// 我们这里需要求解的是nums里面有多少种可以组成target的方式
@@ -135,4 +95,4 @@ var findTargetSumWays = function(nums, S) {
13595

13696
## 扩展
13797

138-
如果这道题目并没有限定所有的元素以及target都是正数怎么办
98+
如果这道题目并没有限定所有的元素以及 target 都是正数怎么办

problems/518.coin-change-2.md

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -123,64 +123,6 @@ return dp[dp.length - 1];
123123
*
124124
* [518] Coin Change 2
125125
*
126-
* https://leetcode.com/problems/coin-change-2/description/
127-
*
128-
* algorithms
129-
* Medium (41.57%)
130-
* Total Accepted: 39.7K
131-
* Total Submissions: 94.6K
132-
* Testcase Example: '5\n[1,2,5]'
133-
*
134-
* You are given coins of different denominations and a total amount of money.
135-
* Write a function to compute the number of combinations that make up that
136-
* amount. You may assume that you have infinite number of each kind of
137-
* coin.
138-
*
139-
*
140-
*
141-
*
142-
*
143-
*
144-
* Example 1:
145-
*
146-
*
147-
* Input: amount = 5, coins = [1, 2, 5]
148-
* Output: 4
149-
* Explanation: there are four ways to make up the amount:
150-
* 5=5
151-
* 5=2+2+1
152-
* 5=2+1+1+1
153-
* 5=1+1+1+1+1
154-
*
155-
*
156-
* Example 2:
157-
*
158-
*
159-
* Input: amount = 3, coins = [2]
160-
* Output: 0
161-
* Explanation: the amount of 3 cannot be made up just with coins of 2.
162-
*
163-
*
164-
* Example 3:
165-
*
166-
*
167-
* Input: amount = 10, coins = [10]
168-
* Output: 1
169-
*
170-
*
171-
*
172-
*
173-
* Note:
174-
*
175-
* You can assume that
176-
*
177-
*
178-
* 0 <= amount <= 5000
179-
* 1 <= coin <= 5000
180-
* the number of coins is less than 500
181-
* the answer is guaranteed to fit into signed 32-bit integer
182-
*
183-
*
184126
*/
185127
/**
186128
* @param {number} amount

0 commit comments

Comments
 (0)