MCPcopy Create free account
hub / github.com/austingebauer/go-leetcode / robInRange

Function robInRange

house_robber_ii_213/solution.go:22–30  ·  view source on GitHub ↗
(nums []int)

Source from the content-addressed store, hash-verified

20}
21
22func robInRange(nums []int) int {
23 dp := make([]int, len(nums)+1)
24 dp[1] = nums[0]
25 for i := 1; i < len(nums); i++ {
26 dp[i+1] = int(math.Max(float64(dp[i]), float64(nums[i]+dp[i-1])))
27 }
28
29 return dp[len(dp)-1]
30}

Callers 1

robFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected