In this code on each for iteration doing like below:
temp = last
last = now
now = max(temp + i, now)
so this code in c++ actually looks like:
last = 0;
now = 0;
for (int i = 0; i < num.length; i++) {
temp = last;
last = now;
now = max(temp + nums[i], now);
}
3
solved House robber in Python Explanation