幂集,也是原集合的所有子集 位运算求幂集 1234567891011121314vector<vector<int>> subsets(vector<int>& nums) { vector<vector<int>>ans; for(int i = 0; i < (1<<nums.size()); i++){ vector<int>vec; for(int j = 0; j < nums.size(); j++){ if(i & (1 << j)) { vec.push_back(nums[j]); } } ans.push_back(vec); } return ans; } ← Previous Post Next Post → FEATURED TAGS 算法 FRIENDS 肖喵喵 Hux Blog