|
@@ -0,0 +1,29 @@
|
|
|
|
|
+import java.util.LinkedList;
|
|
|
|
|
+
|
|
|
|
|
+class Solution {
|
|
|
|
|
+ public List<List<Integer>> findSubsequences(int[] nums) {
|
|
|
|
|
+ Set<LinkedList<Integer>> set = new HashSet<>();
|
|
|
|
|
+ List<LinkedList<Integer>> lists = new LinkedList<>();
|
|
|
|
|
+ for (int i : nums) {
|
|
|
|
|
+ lists.clear();
|
|
|
|
|
+ for (LinkedList<Integer> list : set) {
|
|
|
|
|
+ if (list.getLast() <= i) {
|
|
|
|
|
+ LinkedList<Integer> newList = new LinkedList<>(list);
|
|
|
|
|
+ newList.add(i);
|
|
|
|
|
+ lists.add(newList);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for (LinkedList<Integer> list : lists) {
|
|
|
|
|
+ set.add(list);
|
|
|
|
|
+ }
|
|
|
|
|
+ LinkedList<Integer> list = new LinkedList<>();
|
|
|
|
|
+ list.add(i);
|
|
|
|
|
+ set.add(list);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<List<Integer>> res = new LinkedList<>();
|
|
|
|
|
+ for (List list : set) {
|
|
|
|
|
+ if (1 < list.size()) res.add(list);
|
|
|
|
|
+ }
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|