- 
                            
                            78. SubsetsAlgorithm/java tip 2021. 3. 7. 00:40leetcode.com/problems/subsets/ Subsets - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com class Solution { List<List<Integer>> ret = new ArrayList<>(); public List<List<Integer>> subsets(int[] nums) { List<Integer> subset = new ArrayList<>(); BT(nums, 0, subset); return ret; } public void BT(int[] nums, int index, List<Integer> subset) { if(index == nums.length) { ret.add(new ArrayList<>(subset)); return; } int c = nums[index]; BT(nums, index + 1, subset); subset.add(c); BT(nums, index + 1, subset); subset.remove(subset.size() - 1); } }A general approach to backtracking questions in Java (Subsets, Permutations, Combination Sum, Palindrome Partitioning) - LeetCod Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 'Algorithm > java tip' 카테고리의 다른 글530. Minimum Absolute Difference in BST (0) 2021.03.13 589. N-ary Tree Preorder Traversal (0) 2021.03.13 404. Sum of Left Leaves (0) 2021.03.06 22. Generate Parentheses (0) 2021.03.06 559. Maximum Depth of N-ary Tree (0) 2021.03.06