377. Combination Sum IV 返回符合目標和的組數
阿新 • • 發佈:2018-05-13
not ref XA 返回 amp fin 空間 cor ati
[抄題]:
Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.
Example:
nums = [1, 2, 3] target = 4 The possible combination ways are: (1, 1, 1, 1) (1, 1, 2) (1, 2, 1) (1, 3) (2, 1, 1) (2, 2) (3, 1) Note that different sequences are counted as different combinations. Therefore the output is 7.
[暴力解法]:
時間分析:
空間分析:
[優化後]:
時間分析:
空間分析:
[奇葩輸出條件]:
[奇葩corner case]:
[思維問題]:
[一句話思路]:
[輸入量]:空: 正常情況:特大:特小:程序裏處理到的特殊情況:異常情況(不合法不合理的輸入):
[畫圖]:
[一刷]:
[二刷]:
[三刷]:
[四刷]:
[五刷]:
[五分鐘肉眼debug的結果]:
[總結]:
[復雜度]:Time complexity: O() Space complexity: O()
[英文數據結構或算法,為什麽不用別的數據結構或算法]:
[算法思想:遞歸/分治/貪心]:
[關鍵模板化代碼]:
[其他解法]:
[Follow Up]:
[LC給出的題目變變變]:
[代碼風格] :
377. Combination Sum IV 返回符合目標和的組數