MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / rob

Method rob

java/0213-house-robber-ii.java:3–11  ·  view source on GitHub ↗
(int[] nums)

Source from the content-addressed store, hash-verified

1class Solution {
2
3 public int rob(int[] nums) {
4 if (nums.length == 0) return 0;
5 if (nums.length == 1) return nums[0];
6
7 return Math.max(
8 robHelper(nums, 0, nums.length - 2),
9 robHelper(nums, 1, nums.length - 1)
10 );
11 }
12
13 public int robHelper(int[] nums, int start, int end) {
14 int rob1 = 0;

Callers

nothing calls this directly

Calls 1

robHelperMethod · 0.95

Tested by

no test coverage detected