LeetCode知识点总结 - 377
LeetCode 377. Combination Sum IV
考点 | 难度 |
---|---|
DP | Medium |
题目
Given an array of distinct integers nums
and a target integer target
, return the number of possible combinations that add up to target
.
The test cases are generated so that the answer can fit in a 32-bit integer.
思路
答案
class Solution:def combinationSum4(self, nums: List[int], target: int) -> int:dp = {}dp[0] = [1]def search(target):if target in dp:return dp[target]comb_sum = 0for num in nums:if target > num:comb_sum += search(target - num)elif target == num:comb_sum += 1dp[target] = comb_sumreturn comb_sumreturn search(target)
LeetCode知识点总结 - 377相关推荐
- LeetCode知识点总结 - 884
LeetCode 884. Uncommon Words from Two Sentences 考点 难度 Hash Table Easy 题目 A sentence is a string of s ...
- LeetCode知识点总结 - 868
LeetCode 868. Binary Gap 考点 难度 Math Easy 题目 Given a positive integer n, find and return the longest ...
- LeetCode知识点总结 - 1413
LeetCode 1413. Minimum Value to Get Positive Step by Step Sum 考点 难度 Prefix Sum Easy 题目 Given an arra ...
- LeetCode知识点总结 - 2073
LeetCode 2073. Time Needed to Buy Tickets 考点 难度 Simulation Easy 题目 There are n people in a line queu ...
- LeetCode知识点总结 - 347
LeetCode 347. Top K Frequent Elements 考点 难度 Array Medium 题目 Given an integer array nums and an integ ...
- LeetCode知识点总结 - 997
LeetCode 997. Find the Town Judge 考点 难度 Hash Table Easy 题目 In a town, there are n people labeled fro ...
- LeetCode知识点总结 - 606
LeetCode 606. Construct String from Binary Tree 考点 难度 String Easy 题目 Given the root of a binary tree ...
- LeetCode知识点总结 - 844
LeetCode 844. Backspace String Compare 考点 难度 Simulation Easy 题目 Given two strings s and t, return tr ...
- LeetCode知识点总结 - 977
LeetCode 977. Squares of a Sorted Array 考点 难度 Sorting Easy 题目 Given an integer array nums sorted in ...
最新文章
- npm install是什么命令_了解npm
- swoole基础01
- 本硕皆数学专业,博士转行生物后,他发表了学校首篇Nature
- numpy zeros矩阵_零矩阵使用numpy.zeros()| 使用Python的线性代数
- 2017.5.7 换教室 思考记录
- CentOS 6.3(x86_32)下安装Oracle 10g R2
- 嵌入式系统TinyOS学习资源
- H5自定义属性详细介绍
- 常用邮箱SMTP/POP3地址及端口
- U盘用USBOOT做引导盘后,导致无法格式化U盘
- 科技互联网都有啥热点信息?爬取虎嗅5万篇文章告诉你
- Weighted average
- string复制部分内容
- 自学生物信息学(思维+超全常用网站)
- 【Java】UML类图详解-详细易懂
- 世界热力地图 R语言
- 前端开发者最常用的六款IDE
- 佟刚老师《Spring4视频教程》学习笔记(1)--转载
- 会声会影2023最新版v25.3.0.0视频剪辑软件
- 【强化学习】你应该理解的一些关键概念