In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to solve the problem of home robbery by Java". Interested friends might as well take a look. The method introduced in this paper is simple, fast and practical. Next, let's let the editor take you to learn "how to solve the problem of robbery by Java".
If you want to rob the nth house, you can't rob the nth house, so the money you get from robbing the nth house is the money of the nth family plus the most money obtained by the former Nmai 2 families, that is, f (nmur2) + nums (n). If you don't rob the nth house, the maximum profit is f (nMuth1). We have to go to the larger one, so the dynamic transfer equation is:
F (n) = max (nums [n] + f (nmur2), f (nmur1))
Package mainimport "fmt" func max (return b int) int {if a > b {return a} return b} func rob (nums [] int) int {if len (nums) = 0 {return 0} if len (nums) = 1 {return nums [0]} dp: = make ([] int,len (nums) dp [0] = nums [0] dp [1] = max (nums [0]) Nums [1]) maxVal: = dp [1] for iRu 2 I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.