human
I am working on the file "00_strStr.ipynb".
The first task is:
Implement strStr function in O(n + m) time.
strStr return the first index of the target string in a source string. The length of the target string is m and the length of the source string is n.
If target does not exist in source, just return -1.
2. Subsets
Given a set of distinct integers, return all possible subsets.
Can you write Python code for it?
 ... Can you provide a the Python code you requested?
assistant
#Here is the Python code you requested.

class Solution:
    """
    @param S: The set of numbers.
    @return: A list of lists. See example.
    """
    def subsets(self, S):
        # write your code here
        if len(S) == 0:
            return [[]]
        S.sort()
        res = self.subsets(S[:-1])
        ans = []
        for s in res:
            ans.append(s)
            ans.append(s + [S[-1]])
        return  ans

Solution().subsets([1,2])

class Solution:
    """
    @param S: The set of numbers.
    @return: A list of lists. See example.
    """
    def subsets(self, S):
        # write your code here
        
        self.results = []
        self.subset = []
        S.sort()
        self.search(S, [], 0)
        return self.results
        
        
    def search(self, S, subset, index):
        if index == len(S):
            self.results.append(subset)
            return
        
        self.search(S, subset + [S[index]], index + 1)
        self.search(S, subset, index + 1)

class Solution:
    """
    @param S: The set of numbers.
    @return: A list of lists. See example.
    """
    def subsets(self, S):
        # write your code here
        
        res = [[]]
        S.sort()
        for i in range(len(S)):
            for j in range(len(res)):
                res.append(res[j] + [S[i]])
        return res