robNext
and robNextPlusOne
, to 0 and nums[nums.length - 1]
respectively.i
, calculate the maximum profit current
by comparing robNext
(skip current house) and robNextPlusOne + nums[i]
(rob current house).robNextPlusOne
to robNext
.robNext
to current
.robNext
as the maximum profit that can be robbed.