You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.
Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.
 
Example 1:
Input: nums = [1,2,3,1]
Output: 4
Explanation: Rob house 1 (money = 1) and then rob house 3 (money = 3).
             Total amount you can rob = 1 + 3 = 4.

Example 2:
Input: nums = [2,7,9,3,1]
Output: 12
Explanation: Rob house 1 (money = 2), rob house 3 (money = 9) and rob house 5 (money = 1).
             Total amount you can rob = 2 + 9 + 1 = 12.

 
Constraints:

0 <= nums.length <= 100
0 <= nums[i] <= 400

Difficulty: EASY
Tags: Dynamic programming

Data structures
Skill types: Dynamic programming

Data structures

Starter code:
class Solution:
    def rob(self, nums: List[int]) -> int:
        

Solutions:
class Solution:

	def rob(self, nums: List[int]) -> int:
		if not nums:
			return 0
		if len(nums) < 3:
			return max(nums)
		dp = [0] * len(nums)
		dp[0] = nums[0]
		dp[1] = max(nums[0], nums[1])
		for i in range(2, len(nums)):
			dp[i] = max(dp[i - 2] + nums[i], dp[i - 1])
		return max(dp)


class Solution:

	def rob(self, nums: List[int]) -> int:
		(now, last) = (0, 0)
		for i in nums:
			(last, now) = (now, max(now, last + i))
		return now


class Solution:

	def rob(self, nums: List[int]) -> int:
		n = len(nums)
		if n == 0:
			return 0
		if n == 1:
			return nums[0]
		max_to_i = [None] * n
		max_to_i[0] = nums[0]
		max_to_i[1] = max(nums[0], nums[1])
		for i in range(2, n):
			max_to_i[i] = max(nums[i] + max_to_i[i - 2], max_to_i[i - 1])
		return max_to_i[-1]


class Solution:

	def rob(self, nums: List[int]) -> int:
		n = len(nums)
		if n == 0:
			return 0
		if n <= 2:
			return max(nums)
		else:
			dp = [0 for i in nums]
			dp[0] = nums[0]
			dp[1] = nums[1]
			for i in range(2, n):
				dp[i] = max(dp[i - 1], max((dp[j] + nums[i] for j in range(i - 1))))
			return max(dp)


class Solution:

	def rob(self, nums: List[int]) -> int:
		n = len(nums)
		if n == 0:
			return 0
		if n == 1:
			return nums[0]
		dp = [0] * (n + 1)
		dp[0] = 0
		dp[1] = nums[0]
		a = 1
		while a < n:
			dp[a + 1] = max(dp[a - 1] + nums[a], dp[a])
			a += 1
		return dp[n]


class Solution:

	def rob(self, nums: List[int]) -> int:
		n = len(nums)
		l1 = [0] * n
		if n == 0:
			return 0
		elif n == 1:
			return nums[0]
		elif n == 2:
			return max(nums[0], nums[1])
		(l1[0], l1[1]) = (nums[0], max(nums[0], nums[1]))
		for i in range(2, n):
			l1[i] = max(l1[i - 1], nums[i] + l1[i - 2])
		return max(l1)


class Solution:

	def rob(self, nums: List[int]) -> int:
		if len(nums) == 0:
			return 0
		if len(nums) == 1:
			return nums[0]
		robbed = [nums[0]]
		maxMoney = robbed[0]
		for i in range(1, len(nums)):
			cur = nums[i]
			for j in range(len(robbed) - 1):
				cur = max(nums[i] + robbed[j], cur)
			robbed.append(cur)
			if cur > maxMoney:
				maxMoney = cur
		return maxMoney


class Solution:

	def rob(self, nums: List[int]) -> int:
		prevMax = 0
		currMax = 0
		for num in nums:
			temp = currMax
			currMax = max(prevMax + num, currMax)
			prevMax = temp
		return currMax


class Solution:

	def rob(self, nums: List[int]) -> int:
		if not nums:
			return 0
		size = len(nums)
		max_sums = nums.copy()
		for (i, num) in enumerate(nums):
			for j in range(0, i - 1):
				if 0 <= j < size:
					max_sums[i] = max(max_sums[i], num + max_sums[j])
		return max(max_sums)