@@ -0,0 +1,1095 @@
+package com.flang.dp;%0A%0Apublic class HouseRobber %7B%0A    public static int rob(int%5B%5D nums) %7B%0A        if (nums == null %7C%7C nums.length == 0) %7B%0A            return 0;%0A        %7D%0A        if (nums.length == 1) %7B%0A            return nums%5B0%5D;%0A        %7D%0A        int%5B%5D dp = new int%5Bnums.length%5D;%0A        dp%5B0%5D = nums%5B0%5D;%0A        dp%5B1%5D = Math.max(nums%5B1%5D, nums%5B0%5D);%0A        for (int i = 2; i %3C nums.length; i++) %7B%0A            dp%5Bi%5D = Math.max(dp%5Bi-1%5D, dp%5Bi-2%5D + nums%5Bi%5D);%0A        %7D%0A        return dp%5Bnums.length-1%5D;%0A    %7D%0A%0A    public static int robSlidingWindow(int%5B%5D nums) %7B%0A        if (nums == null %7C%7C nums.length == 0) %7B%0A            return 0;%0A        %7D%0A        if (nums.length == 1) %7B%0A            return nums%5B0%5D;%0A        %7D%0A        int first = nums%5B0%5D;%0A        int second = Math.max(nums%5B1%5D, nums%5B0%5D);%0A        for (int i = 2; i %3C nums.length; i++) %7B%0A            int temp = second;%0A            second = Math.max(second, first + nums%5Bi%5D);%0A            first = temp;%0A        %7D%0A        return second;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        System.out.println(rob(new int%5B%5D%7B1,2,3,1%7D));%0A    %7D%0A%7D%0A

Create HouseRobber.java