This commit is contained in:
programmercarl
2023-02-08 17:28:04 +08:00
parent d107b53a4a
commit 1ec9d9bcb4
22 changed files with 146 additions and 148 deletions

View File

@@ -7,7 +7,7 @@
# 494. 目标和
# 494.目标和
[力扣题目链接](https://leetcode.cn/problems/target-sum/)
@@ -19,15 +19,15 @@
示例:
输入nums: [1, 1, 1, 1, 1], S: 3
输出5
* 输入nums: [1, 1, 1, 1, 1], S: 3
* 输出5
解释:
-1+1+1+1+1 = 3
+1-1+1+1+1 = 3
+1+1-1+1+1 = 3
+1+1+1-1+1 = 3
+1+1+1+1-1 = 3
* -1+1+1+1+1 = 3
* +1-1+1+1+1 = 3
* +1+1-1+1+1 = 3
* +1+1+1-1+1 = 3
* +1+1+1+1-1 = 3
一共有5种方法让最终目标和为3。
@@ -37,6 +37,11 @@
* 初始的数组的和不会超过 1000 。
* 保证返回的最终结果能被 32 位整数存下。
# 算法公开课
**《代码随想录》算法视频公开课:[装满背包有多少种方法?| LeetCode494.目标和](https://www.bilibili.com/video/BV1o8411j73x/),相信结合视频再看本篇题解,更有助于大家对本题的理解**。
## 思路
如果对背包问题不都熟悉先看这两篇: