解决思路动态规划 解决思路 动态规划 public int rob(int[] num){ int preMax = 0; int currMax = 0; for (int i:num){ int temp = currMax; currMax = Math.max(preMax + i,currMax); preMax = temp; } return currMax; }