Why my solution using Python met a Memory Limit Exceeded error ?


  • 0
    S
    class Solution:
        # @param n, an integer
        # @return an integer
        def climbStairs(self, n):
            if n == 0 or n == 1:
                return n
            else:
                return reduce(lambda x,y: x+y, [len(list(itertools.combinations(range(n),x+1))) for x in range(n/2)]) + 1

  • 0
    J

    You can try generator(yield)...................................


Log in to reply
 

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