House Robber
https://leetcode.com/problems/house-robber/ 隣り合った家は訪れることが出来ないので、 変数 rob1 と rob2 を用意する。 for で全ての家を訪れ、 pointer のある位置+rob1 と rob2 の大きい値を temp に入れる。 rob1 pointerのある位置の前の前の家 rob2 pointerのある位置のは前の家 rob2 が nums の最後の位置まで行くとループが終わるので return で rob2 を返す。 class Solution: def rob(self, num: List[int])-> int: rob1, rob2 = 0, 0 for n in num: temp = max(rob1 + n, rob2) rob1 = rob2 rob2 = temp return rob2