Problem 2417. all possible subsets of set

Created by rifat in Community

Given a vector, return all possible subsets of the vector in a cell array. Properties of basic set theory is assumed to be valid here e.g no repeated element, empty-set being a subset etc. Consider NaNs to be equal for this problem. Within a subset, sort all the elements. Any NaNs should appear at the beginning in the sorted subset.


Input : x=[1 2 3];
Output: y ={[],[1],[2],[3],[1 2],[1 3],[2 3],[1 2 3]};

Solution Stats

50.85% Correct | 49.15% Incorrect
Last solution submitted on Apr 10, 2019