一:题目
二:上码
class Solution {
List> ans = new ArrayList<>();
List path = new ArrayList<>();
public boolean getIcrease(List nums) {
for (int i = 0;i < nums.size(); i++) {
if (i-1 >= 0 && nums.get(i) < nums.get(i-1)) return false;
}
return true;
}
public void getAns(int[] nums,int st) {
if (path.size() >= 2 && getIcrease(path)) {
ans.add(new ArrayList<>(path));
}
Map map = new HashMap<>();
for (int i = st; i < nums.length; i++) {
map.put(nums[i],map.getOrDefault(nums[i],0)+1);
if (map.getOrDefault(nums[i],0) > 1) continue;
path.add(nums[i]);
getAns(nums,i+1);
path.remove(path.size()-1);
}
}
public List> findSubsequences(int[] nums) {
getAns(nums,0);
return ans;
// int[] ll = {4,4};
// System.out.println(getIcrease(ll));
// return ans;
}
}