Simple python solution with bit operation

  • 1
    class Solution:
        # @param S, a list of integer
        # @return a list of lists of integer
        def subsets(self, S):
            n = len(S);
            S = sorted(S)
            result = [];
            for i in xrange(1<<n):
                temp = []
                for j in xrange(n):
                    if i & (1<<j) > 0:
            return result;

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.