python dp 25ms beats 100% python solutions


  • 0
    P
        def rob(self, arrHouseValues):
            prev1, prev2 = 0, 0
            for i in range(len(arrHouseValues)-1, -1, -1):
                result = max(prev2 + arrHouseValues[i], prev1)
                prev2, prev1 = prev1, result
            return prev1
    

Log in to reply
 

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