class Solution {
public:
vector<int> temp;
vector< vector<int> > ans;
void print(vector<int> &S, int index, int end) {
if( index == end ) {
return;
}
temp.push_back(S[index]);
ans.push_back(temp);
print(S,index+1,end);
temp.pop_back();
}
vector<vector<int> > subsets(vector<int> &S) {
sort(S.begin(), S.end());
int len = 1 << S.size();
for( int i = 0 ; i < len ; i++ ) {
for( int j = 0 ; j < S.size() ; j++ ) {
if( i & (1 << j) ) {
temp.push_back(S[j]);
}
}
ans.push_back(temp);
temp.clear();
}
return ans;
}
};
System Design for Beginners
A masterclass that helps early engineers and product managers become great at designing scalable systems.
132+ learners
Details →System Design Masterclass
A masterclass that helps you become great at designing scalable, fault-tolerant, and highly available systems.
1000+ learners
Details →Redis Internals
Learn internals of Redis by re-implementing some of the core features in Golang.
98+ learners
Details →