4 lines python solution


  • 1
    S
    class Solution(object):
        def rob(self, nums):
    
            m_low = m_high = 0
            
            for n in nums:
                m_high, m_low = max(m_low + n, m_high), m_high
    
            return m_high

Log in to reply
 

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