剑指 Offer II 104. 排列的数目

换下顺序就是排列数??


 func combinationSum4(_ nums: [Int], _ target: Int) -> Int {
        var dp = Array.init(repeating: 0, count: target + 1)
        dp[0] = 1
        for i in 0...target {
            for num in nums {
                if i < num || dp[i] > Int.max - dp[i - num]{
                   continue
                }
                dp[i] += dp[i - num]
            }
            
        }
                
        return dp.last!
    }







你可能感兴趣的:(剑指 Offer II 104. 排列的数目)