-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a1543c
commit 1de7fad
Showing
7 changed files
with
57 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
## [subsets](leetcode.com/problems/subsets) | ||
- | ||
## [subsets](https://leetcode.com/problems/subsets) | ||
- | ||
|
||
## [generateParenthesis] (https://leetcode.com/problems/generate-parentheses/) | ||
- base case when str == max length * 2, open + close parenthsis | ||
- num open parenthsis must equal num close parenthsis. | ||
- n = 3 =>> “((()))”, “(()())”, “(())()”, “()(())”, “()()()” |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class Subsets { | ||
// // generate all "non-duplicates" subsets of a given array | ||
public List<List<Integer>> subsets(int[] nums) { | ||
List<List<Integer>> output = new ArrayList<>(); | ||
output.add(new ArrayList<Integer>()); | ||
|
||
for (int num : nums) { | ||
int size = output.size(); | ||
for (int i = 0; i < size; i++) { | ||
List<Integer> subset = new ArrayList<>(output.get(i)); | ||
subset.add(num); | ||
output.add(subset); | ||
} | ||
} | ||
return output; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## [subsets](leetcode.com/problems/subsets) | ||
- **O(N*2^N)**, **O(N*2^N)** N nums of elements, 2^N subsets. | ||
- start with empty set, add each element to set, then add to result. | ||
- [[], [1], [5], [1,5], [3], [1,3], [5,3], [1,5,3]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
- revise two pointer interview school | ||
- revise two pointer interview school | ||
- return next to recursion DP, Backtracking |