From 7cdd4170947e39a8d206b4b329f18140a66413bb Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Fri, 13 Mar 2020 23:41:17 +0800 Subject: [PATCH] Remove temporary variable --- algorithms/dp/house_robber.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/algorithms/dp/house_robber.py b/algorithms/dp/house_robber.py index a2a8a6d92..5a359f93d 100644 --- a/algorithms/dp/house_robber.py +++ b/algorithms/dp/house_robber.py @@ -15,7 +15,5 @@ def house_robber(houses): last, now = 0, 0 for house in houses: - tmp = now - now = max(last + house, now) - last = tmp + last, now = now, max(last + house, now) return now