From 75c4bd847323015665667b88279b462cc6f6ea47 Mon Sep 17 00:00:00 2001 From: asahi Date: Thu, 24 Jul 2025 21:40:20 +0800 Subject: [PATCH] =?UTF-8?q?leetcode=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 39.combination-sum.java | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 39.combination-sum.java diff --git a/39.combination-sum.java b/39.combination-sum.java new file mode 100644 index 0000000..b434eac --- /dev/null +++ b/39.combination-sum.java @@ -0,0 +1,42 @@ +/* + * @lc app=leetcode id=39 lang=java + * + * [39] Combination Sum + */ + +// @lc code=start +class Solution { + public List> combinationSum(int[] candidates, int target) { + int[] copyArr = copy(candidates); + Arrays.sort(copyArr); + List> combList = new ArrayList>(); + + } + + private void dfsCombinations(int[] arr, int i, int cur, int target, List curList, List> combList) { + if(cur > target) { + return; + } else if (cur == target) { + combList.add(copy(curList)); + return; + } + // + } + + private List copy(List comb) { + return new ArrayList(comb); + } + + private int[] copy(int[] arr) { + if(arr == null) { + return null; + } + int[] r = new int[arr.length]; + for(int i = 0; i < arr.length; i++) { + r[i] = arr[i]; + } + return r; + } +} +// @lc code=end +