# LeetCode Increasing Subsequences

LeetCode Increasing Subsequences

Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing subsequence should be at least 2 .

Example:

```Input: [4, 6, 7, 7]
Output: [[4, 6], [4, 7], [4, 6, 7], [4, 6, 7, 7], [6, 7], [6, 7, 7], [7,7], [4,7,7]]
```

Note:

1. The length of the given array will not exceed 15.
2. The range of integer in the given array is [-100,100].
3. The given array may contain duplicates, and two equal integers should also be considered as a special case of increasing sequence.

set去重：还会遇到这样的样例比如样例[4,6,7,4,8,9,10]，第一个4DFS的结果包含了第二个4DFS的结果，但是这两个4不相邻，所以不能被第19行的条件防止重复，只能用set去重了。

```class Solution {
private:
void dfs(set<vector<int>>& ans, vector<int>& nums, vector<int>& cand, int start){
if(cand.size() >= 2)ans.insert(cand);
for(int i = start + 1; i < nums.size(); ++i){
if(i == start + 1 || nums[i] != nums[i - 1]){
if(nums[i] >= cand[cand.size() - 1]){
cand.push_back(nums[i]);
dfs(ans, nums, cand, i);
cand.pop_back();
}
}
}
}
public:
vector<vector<int>> findSubsequences(vector<int>& nums) {
set<vector<int>> ans;
for(int i = 0; i < nums.size(); ++i){
if(i == 0 || nums[i] != nums[i-1]){
vector<int> cand = {nums[i]};
dfs(ans, nums, cand, i);
}
}
return vector<vector<int>>(ans.begin(), ans.end());
}
};
```