Clean python code


  • 0
    class Solution(object):
        def _rob(self, nums):
            fn_1 = fn_2 = 0
            for i in xrange(len(nums)):
                fn_1, fn_2 = max(fn_2 + nums[i], fn_1), fn_1
            return fn_1
    
        def rob(self, nums):
            return nums and max(self._rob(nums[1:]), self._rob(nums[2:-1]) + nums[0]) or 0

Log in to reply
 

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