首页 > 其他 > 详细

377. Combination Sum IV (DP)

时间:2018-08-02 23:50:14      阅读:166      评论:0      收藏:0      [点我收藏+]
 1 class Solution {
 2     public int combinationSum4(int[] nums, int target) {
 3         int[] res = new int[target + 1];
 4         res[0] = 1;
 5         for(int i = 1; i <= target; i++) {
 6             for(int j = 0; j < nums.length; j++) {
 7                 if(nums[j] <= i && res[i - nums[j]] > 0) {
 8                     res[i] += res[i - nums[j]] ;
 9                 }
10             }
11         }
12         return res[target];
13 
14         
15     }
16 }

 

377. Combination Sum IV (DP)

原文:https://www.cnblogs.com/goPanama/p/9410842.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!