Write a python Class to print All Possible Subsets from a Set of Distinct Integers
Topic: Write a python Class to print All Possible Subsets from a Set of Distinct Integers
Solution
class sub: def f1(self, s1): return self.f2([], sorted(s1)) def f2(self, curr, s1): if s1: return self.f2(curr, s1[1:]) + self.f2(curr + [s1[0]], s1[1:]) return [curr] a=[2, 3, 5, 6, 4, 5] print("Subsets: ") print(sub().f1(a))
List all Python Programs