当前位置:网站首页>213. house raiding II

213. house raiding II

2022-06-11 07:01:00 Not coriander

You are a professional thief , Plan to steal houses along the street , There is a certain amount of cash in every room . All the houses in this place are Make a circle , This means that the first house and the last house are next to each other . meanwhile , Adjacent houses are equipped with interconnected anti-theft system , If two adjacent houses are broken into by thieves on the same night , The system will automatically alarm .

Given an array of non negative integers representing the storage amount of each house , Count you Without triggering the alarm device , The maximum amount you can steal tonight .

Example 1:

 Input :nums = [2,3,2]
 Output :3
 explain : You can't steal first  1  House No ( amount of money  = 2), And then steal  3  House No ( amount of money  = 2,  Because they are next to each other .

Example 2:

 Input :nums = [1,2,3,1]
 Output :4
 explain : You can steal first  1  House No ( amount of money  = 1), And then steal  3  House No ( amount of money  = 3).
      Maximum amount stolen  = 1 + 3 = 4 .

Example 3:

 Input :nums = [0]
 Output :0

Tips :

1 <= nums.length <= 100
0 <= nums[i] <= 1000
原网站

版权声明
本文为[Not coriander]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020524020240.html