The problem is similar to the stock buy and sell ones, but is there a given name to the specific approach to this kind of problem? I'm asking if there's a name like those DP, Divide and Conquer, Binary, etc..

```
public class Solution {
public int rob(int[] num) {
if(num==null||num.length==0) return 0;
if(num.length==1) return num[0];
if(num.length==2) return Math.max(num[0],num[1]);
int prev=num[0];
int curr=Math.max(num[0],num[1]);
for(int i=2;i<num.length;i++){
int temp=Math.max(curr,num[i]+prev);
prev=curr;
curr=temp;
}
return curr;
}
}
```