class Solution {
public:
vector<vector<int>> ans;
vector<int> path;
void dfs(vector<int> nums,int idx)//选择path的下一个数填什么,从下标idx开始选
{
if(path.size()>=2) ans.push_back(path);
if(idx==nums.size())
return;
set<int> s;
for(int i=idx;i<nums.size();i++)
if(path.empty()||nums[i]>=path.back())
{
if(s.count(nums[i])) continue;
s.insert(nums[i]);
path.push_back(nums[i]);
dfs(nums,i+1);
path.pop_back();
}
}
vector<vector<int>> findSubsequences(vector<int>& nums) {
dfs(nums,0);
return ans;
}
};
标签:idx,nums,递增,back,491,vector,ans,path,LeetCode
From: https://www.cnblogs.com/tangxibomb/p/17472723.html