Python 刷Leetcode题库,顺带学英语单词(43)
House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night. [#198]
Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.
Example 1:
Input: [1,2,3,1]
Output: 4
Explanation: Rob house 1 (money = 1) and then rob house 3 (money = 3).
Total amount you can rob = 1 + 3 = 4.
Example 2:
Input: [2,7,9,3,1]
Output: 12
Explanation: Rob house 1 (money = 2), rob house 3 (money = 9) and rob house 5
(money = 1).
Total amount you can rob = 2 + 9 + 1 = 12.
House Robber II
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night. [#213]
Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.
Example 1:
Input: [2,3,2]
Output: 3
Explanation: You cannot rob house 1 (money = 2) and then rob house 3 (money = 2), because they are adjacent houses.
Example 2:
Input: [1,2,3,1]
Output: 4
Explanation: Rob house 1 (money = 1) and then rob house 3 (money = 3). Total amount you can rob = 1 + 3 = 4.
相关文章
- Python项目44-前后端分离项目(前戏)
- Python面试基础知识_python自学需要哪些基础知识
- Python怎么输入小数和整数_python输入非负整数
- Python常用代码_python画图代码大全
- aic准则python_Python数据科学:线性回归
- python解压bz2文件命令_解压缩bz2文件
- Python&R语言-python和r相遇
- python中关于命名的例子_Python 命名规范入门实例「建议收藏」
- python dropna()用法「建议收藏」
- python层次聚类分析_SPSS聚类分析:系统聚类分析[通俗易懂]
- python里面的缩进是什么意思_Python缩进规则(一看即懂)[通俗易懂]
- python制作自动交易程序_Python如何实现自动化交易
- Python 生成随机数_python 随机字符串
- 我与Python爬虫的初次邂逅
- eval在python中是什么意思_如何在Python中使用eval ?
- 【测试开发】python系列教程:Python 推导式
- Python 内置界面开发框架 Tkinter入门篇 乙
- Python 第二次作业及解答
- Python面向对象编程-三大特性-继承-覆盖和重写
- Ubuntu18.04 一键升级Python所有第三方包 及安装python包的方法
- 掌握Python访问MySQL的新技能(python访问mysql)
- 在Linux上学习Python——你的编程之路(linux学python)
- Python与MongoDB 无缝连接(python连接mongodb)
- Python脚本实现Linux系统管理及自动化部署(python写linux)
- 利用Neo4j和Python进行无缝图形数据库支持(neo4j python)
- Python实现MySQL数据库的读取(python读取mysql)
- MySQL与Python的协同运行:一种全新的开发体验(mysql与python)
- Python程序设计入门(5)类的使用简介
- python的类变量和成员变量用法实例教程