Skip to content

Commit 1cdaece

Browse files
[LEET-0000] clean up
1 parent 62a817e commit 1cdaece

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

leetcode-algorithms/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,15 @@
256256
|53|[Maximum Subarray](https://leetcode.com/problems/maximum-subarray/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/MaximumSubarray.java)|O(n)|O(1)|Medium|
257257
|50|[Pow(x, n)](https://leetcode.com/problems/powx-n/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/PowXN.java)|O(logn)|O(logn)|Medium|
258258
|47|[Permutations II](https://leetcode.com/problems/permutations-ii/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/PermutationsII.java)|O(n*n!)|O(n)|Medium|Backtracking
259+
|46|[Permutations](https://leetcode.com/problems/permutations/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/Permutations.java)|O(n*n!)|O(n)|Medium|Backtracking
259260
|45|[Jump Game II](https://leetcode.com/problems/jump-game-ii/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/JumpGameII.java)|O(?)|O(?)|Hard|
260261
|43|[Multiply Strings](https://leetcode.com/problems/multiply-strings/)|[Solution]|||Medium
261262
|42|[Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/TrappingRainWater.java)|O(n)|O(1)|Hard|
262263
|41|[First Missing Positive](https://leetcode.com/problems/first-missing-positive/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/FirstMissingPositive.java)|O(n)|O(1)|Hard|
264+
|40|[Combination Sum II](https://leetcode.com/problems/combination-sum-ii/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/CombinationSumII.java)|O(k*n^k)|O(k)|Medium|Backtracking
263265
|39|[Combination Sum](https://leetcode.com/problems/combination-sum/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/CombinationSum.java)|O(k*n^k)|O(k)|Medium|Backtracking
264266
|38|[Count and Say](https://leetcode.com/problems/count-and-say/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/CountandSay.java)|O(n*2^n)|O(2^n)|Easy| Recursion, LinkedList
267+
|36|[Valid Sudoku](https://leetcode.com/problems/valid-sudoku/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/ValidSudoku.java)|O(?)|O(?)|Medium|
265268
|35|[Search Insert Position](https://leetcode.com/problems/search-insert-position/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/SearchInsertPosition.java)|O(n)|O(1)|Medium|Array
266269
|34|[Search for a Range](https://leetcode.com/problems/search-for-a-range/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/SearchForARange.java)|O(logn)|O(1)|Medium|Array, Binary Search
267270
|33|[Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/SearchinRotatedSortedArray.java)|O(logn)|O(1)|Hard|Binary Search
@@ -270,6 +273,8 @@
270273
|30|[Substring with Concatenation of All Words](https://leetcode.com/problems/substring-with-concatenation-of-all-words/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/SubstringwithConcatenationofAllWords.java)|O(n^2)|O(n)|Hard| HashMap
271274
|29|[Divide Two Integers](https://leetcode.com/problems/divide-two-integers/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/DivideTwoIntegers.java)|O(?)|O(?)|Medium|
272275
|28|[Implement strStr()](https://leetcode.com/problems/implement-strstr/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/ImplementStrStr.java)|O(n)|O(1)|Easy| String
276+
|27|[Remove Element](https://leetcode.com/problems/remove-element/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/RemoveElement.java)|O(n)|O(1)| Easy |
277+
|26|[Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/RemoveDuplicatesFromSortedArray.java)|O(n)|O(1)|Easy|
273278
|25|[Reverse Nodes in k-Group](https://leetcode.com/problems/reverse-nodes-in-k-group/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/ReverseNodesinkGroup.java)|O(n)|O(1)| Hard | Recursion, LinkedList
274279
|24|[Swap Nodes in Pairs](https://leetcode.com/problems/swap-nodes-in-pairs/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/SwapNodesinPairs.java)|O(n)|O(1)|Easy| Recursion, LinkedList
275280
|23|[Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists/)|[Solution](../../master/leetcode-algorithms/src/main/java/com/stevesun/solutions/MergeKSortedList.java)|O(n*logk)|O(logk)|Hard|Heap

leetcode-algorithms/src/main/java/com/stevesun/solutions/CombinationSumII.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,23 @@
55
import java.util.ArrayList;
66
import java.util.Arrays;
77
import java.util.List;
8-
8+
/***Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.
9+
10+
Each number in C may only be used once in the combination.
11+
12+
Note:
13+
All numbers (including target) will be positive integers.
14+
The solution set must not contain duplicate combinations.
15+
For example, given candidate set [10, 1, 2, 7, 6, 1, 5] and target 8,
16+
A solution set is:
17+
[
18+
[1, 7],
19+
[1, 2, 5],
20+
[2, 6],
21+
[1, 1, 6]
22+
]*/
923
public class CombinationSumII {
1024

11-
1225
public List<List<Integer>> combinationSum2(int[] candidates, int target) {
1326
List<List<Integer>> result = new ArrayList();
1427
Arrays.sort(candidates);
@@ -30,7 +43,6 @@ void helper(int[] candidates, int target, int start, List<Integer> curr, List<Li
3043
}
3144
}
3245

33-
3446
public static void main(String...args){
3547
CombinationSumII test = new CombinationSumII();
3648
int[] candidates = new int[]{10,1,2,7,6,1,5};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy