Power Set – algorithmic and fast

class Solution: # @param A : list of integers # @return a list of list of integers def subsets(self, A):     if len(A) == 0:         return [[]]     h, t = A[0], A[1:]     subsets_excluding_h = self.subsets(t)     subsets_including_h = [sorted([h] + ss) for ss in subsets_excluding_h] […]

Atoi

class Solution: # @param A : string # @return an integer def atoi(self, A): mx = (2**31)-1 mn = -(2**31) s = ” for x in A: if x.isdigit() or (A.index(x)==0 and x in (‘-‘, ‘+’)): s += x else: break if (s and s[0].isdigit()) or (len(s)>1 and s[0] in (‘+’, ‘-‘)): if 0 <= […]