<gouthampradhan>dynamic_programming_HouseRobberII_1.java
public int rob(int[] nums) {
    if (nums.length == 0) return 0;
    if (nums.length == 1) return nums[0];
    else if (nums.length == 2) {
      if (nums[0] > nums[1]) return nums[0];
      return nums[1];
    } else if (nums.length == 3) return Math.max(Math.max(nums[0], nums[1]), nums[2]);
    int[] DP = new int[nums.length];
    for (int i = nums.length - 1; i > 0; i--) {
      if (i + 3 < nums.length) DP[i] = Math.max(nums[i] + DP[i + 2], nums[i] + DP[i + 3]);
      else if (i + 2 < nums.length) DP[i] = nums[i] + DP[i + 2];
      else DP[i] = nums[i];
    }
    int max = Math.max(DP[1], DP[2]);
    Arrays.fill(DP, 0); 
    for (int i = nums.length - 2; i >= 0; i--) {
      if (i + 3 < nums.length) DP[i] = Math.max(nums[i] + DP[i + 2], nums[i] + DP[i + 3]);
      else if (i + 2 < nums.length) DP[i] = nums[i] + DP[i + 2];
      else DP[i] = nums[i];
    }
    max = Math.max(max, Math.max(DP[0], DP[1]));
    return max;
  }
public int sample_funcname ( int [ ] var_0 ) {
  if ( var_0 . length == 0 ) return 0 ;
  if ( var_0 . length == 1 ) return var_0 [ 0 ] ;
  else if ( var_0 . length == 2 ) {
    if ( var_0 [ 0 ] > var_0 [ 1 ] ) return var_0 [ 0 ] ;
    return var_0 [ 1 ] ;
  }
  else if ( var_0 . length == 3 ) return Math . max ( Math . max ( var_0 [ 0 ] , var_0 [ 1 ] ) , var_0 [ 2 ] ) ;
  int [ ] var_8 = new int [ var_0 . length ] ;
  for ( int var_9 = var_0 . length - 1 ;
  var_9 > 0 ;
  var_9 -- ) {
    if ( var_9 + 3 < var_0 . length ) var_8 [ var_9 ] = Math . max ( var_0 [ var_9 ] + var_8 [ var_9 + 2 ] , var_0 [ var_9 ] + var_8 [ var_9 + 3 ] ) ;
    else if ( var_9 + 2 < var_0 . length ) var_8 [ var_9 ] = var_0 [ var_9 ] + var_8 [ var_9 + 2 ] ;
    else var_8 [ var_9 ] = var_0 [ var_9 ] ;
  }
  int max = Math . max ( var_8 [ 1 ] , var_8 [ 2 ] ) ;
  Arrays . fill ( var_8 , 0 ) ;
  for ( int var_9 = var_0 . length - 2 ;
  var_9 >= 0 ;
  var_9 -- ) {
    if ( var_9 + 3 < var_0 . length ) var_8 [ var_9 ] = Math . max ( var_0 [ var_9 ] + var_8 [ var_9 + 2 ] , var_0 [ var_9 ] + var_8 [ var_9 + 3 ] ) ;
    else if ( var_9 + 2 < var_0 . length ) var_8 [ var_9 ] = var_0 [ var_9 ] + var_8 [ var_9 + 2 ] ;
    else var_8 [ var_9 ] = var_0 [ var_9 ] ;
  }
  max = Math . max ( max , Math . max ( var_8 [ 0 ] , var_8 [ 1 ] ) ) ;
  return max ;
}
