public int Rob(int[] nums)
{
int len = nums.Length;
int v2 = 0;
int v1 = 0;
for (int i = 0; i < len; i++)
{
int v = v1 > nums[i] + v2 ? v1 : nums[i] + v2;
v2 = v1;
v1 = v;
}
return v1;
}

public class Solution {
public int rob(int[] num) {
int rob = 0, noRob = 0;
for (int i = 0; i < num.length; i++) {
int temp = noRob;
noRob = Math.max(rob, noRob);
rob = temp + num[i];
}
return Math.max(rob, noRob);
}
}

well, the solution is correct, but the explanation is wrong,
pre is the max value at i-2
and cur is the max value at i-1, that's why you update pre and cur after you get temp, which is the max value at i.