198 House Robber
You is a professional robber planning to rob houses along a street. Each house have a certain amount of money stashed, the only constraint stopping all from robbing each of the them are that Adjac ENT houses have security system connected and it would automatically contact the police if the adjacent houses were broken Into on the same night.
Given a list of non-negative integers representing the amount of money in each house, determine the maximum amount of mone Y you can rob tonight without alerting the police.
Credits:
Special thanks to @ifanchu for adding this problem and creating all test cases. Also thanks to @ts for adding additional test cases.
Class solution (Object): def Rob (Self, Nums): "" " : Type Nums:list[int] : Rtype:int " "", now = 0,0 for i in Nums: Last , now= now, Max (Last+i, now) return today # Redo This later # n,m = 1,2
# n,m = n+m, n variables on the left side present the original ones # n==3,m==1
Leetcode with Python-Dynamic programming