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相关推荐

  1. LeetCode知识点总结 - 884

    LeetCode 884. Uncommon Words from Two Sentences 考点 难度 Hash Table Easy 题目 A sentence is a string of s ...

  2. LeetCode知识点总结 - 868

    LeetCode 868. Binary Gap 考点 难度 Math Easy 题目 Given a positive integer n, find and return the longest ...

  3. LeetCode知识点总结 - 1413

    LeetCode 1413. Minimum Value to Get Positive Step by Step Sum 考点 难度 Prefix Sum Easy 题目 Given an arra ...

  4. LeetCode知识点总结 - 2073

    LeetCode 2073. Time Needed to Buy Tickets 考点 难度 Simulation Easy 题目 There are n people in a line queu ...

  5. LeetCode知识点总结 - 347

    LeetCode 347. Top K Frequent Elements 考点 难度 Array Medium 题目 Given an integer array nums and an integ ...

  6. LeetCode知识点总结 - 997

    LeetCode 997. Find the Town Judge 考点 难度 Hash Table Easy 题目 In a town, there are n people labeled fro ...

  7. LeetCode知识点总结 - 606

    LeetCode 606. Construct String from Binary Tree 考点 难度 String Easy 题目 Given the root of a binary tree ...

  8. LeetCode知识点总结 - 844

    LeetCode 844. Backspace String Compare 考点 难度 Simulation Easy 题目 Given two strings s and t, return tr ...

  9. LeetCode知识点总结 - 977

    LeetCode 977. Squares of a Sorted Array 考点 难度 Sorting Easy 题目 Given an integer array nums sorted in ...

最新文章

  1. npm install是什么命令_了解npm
  2. swoole基础01
  3. 本硕皆数学专业,博士转行生物后,他发表了学校首篇Nature
  4. numpy zeros矩阵_零矩阵使用numpy.zeros()| 使用Python的线性代数
  5. 2017.5.7 换教室 思考记录
  6. CentOS 6.3(x86_32)下安装Oracle 10g R2
  7. 嵌入式系统TinyOS学习资源
  8. H5自定义属性详细介绍
  9. 常用邮箱SMTP/POP3地址及端口
  10. U盘用USBOOT做引导盘后,导致无法格式化U盘
  11. 科技互联网都有啥热点信息?爬取虎嗅5万篇文章告诉你
  12. Weighted average
  13. string复制部分内容
  14. 自学生物信息学(思维+超全常用网站)
  15. 【Java】UML类图详解-详细易懂
  16. 世界热力地图 R语言
  17. 前端开发者最常用的六款IDE
  18. 佟刚老师《Spring4视频教程》学习笔记(1)--转载
  19. 会声会影2023最新版v25.3.0.0视频剪辑软件
  20. 【强化学习】你应该理解的一些关键概念

热门文章

  1. <LandingSite>Focusing Locator识别定位器ID
  2. 自学数据结构与算法——绪论
  3. 2022-2027(新版)中国硅胶鼻导管行业需求规模与竞争前景预测报告
  4. 人民币银行结算账户管理办法实施细则
  5. ups电源测试软件,【最新】UPS测试方法和步骤
  6. MAUI 入门教程系列(4.通用主机)
  7. 使用双视场测量工件长度尺寸
  8. 看不见硝烟的战场 人工智能如何运用到网络作战?
  9. 无重复字符的最长子串(加注释)
  10. 计算机初级职称多久能拿证,请问助理工程师多久可以评下来及费用多少