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

Method helper

python/0213-house-robber-ii.py:5–12  ·  view source on GitHub ↗
(self, nums)

Source from the content-addressed store, hash-verified

3 return max(nums[0], self.helper(nums[1:]), self.helper(nums[:-1]))
4
5 def helper(self, nums):
6 rob1, rob2 = 0, 0
7
8 for n in nums:
9 newRob = max(rob1 + n, rob2)
10 rob1 = rob2
11 rob2 = newRob
12 return rob2

Callers 1

robMethod · 0.95

Calls 1

maxFunction · 0.50

Tested by

no test coverage detected