提交时间:2023-11-20 14:01:48
运行 ID: 111372
#include<bits/stdc++.h> using namespace std; class Solution { private: vector<vector<int> > result; vector<int> path; void backtracking(vector<int>& nums, int startIndex) { if(path.size()>1) { result.push_back(path); } int used[201] = {0}; for(int i = startIndex; i < nums.size();i++) { if((!path.empty() && nums[i] < path.back())||used[nums[i]+100]==1) { continue; } used[nums[i] + 100] = 1; path.push_back(nums[i]); backtracking(nums, i + 1); path.pop_back(); } } public: vector<vector<int> > findSubsequences(vector<int>& nums) { result.clear(); path.clear(); backtracking(nums , 0); return result; } };