动态规划
class Solution:
def rob(self, nums: List[int]) -> int:
# 数组长度
n = len(nums)
if n == 1:
return nums[0]
# 打家劫舍1中的函数
def rob1(start, end):
if start == end:
return nums[start]
# 动态规划指针
first = 0
second = nums[start]
third = nums[start]
# 动态规划操作
for i in range(start+2, end+2):
third = max(second, first+nums[i-1])
first = second
second = third
return third
return max(rob1(0, n-2), rob1(1, n-1))
sql练习
607. 销售员
小黑代码
# Write your MySQL query statement below
SELECT
name
FROM
SalesPerson
WHERE
name NOT IN
(SELECT
SalesPerson.name
FROM
SalesPerson LEFT JOIN Orders ON SalesPerson.sales_id = Orders.sales_id
LEFT JOIN Company ON Orders.com_id = Company.com_id
WHERE
Company.name = 'RED')
小黑看完官方题解后
# Write your MySQL query statement below
SELECT
name
FROM
SalesPerson
WHERE
sales_id NOT In
(SELECT
sales_id
FROM
Orders, Company
WHERE
Company.name = 'RED' AND Orders.com_id = Company.com_id
)
Pandas练习
607. 销售员
import pandas as pd
def sales_person(sales_person: pd.DataFrame, company: pd.DataFrame, orders: pd.DataFrame) -> pd.DataFrame:
# 表连接
df = orders.merge(company, how='inner', left_on='com_id', right_on='com_id')[['sales_id', 'name']]
# 筛选RED对应sale_id
RED_sales_id = set(df[df['name'] == 'RED']['sales_id'])
# NOT IN操作
return sales_person[~sales_person['sales_id'].isin(RED_sales_id)][['name']]
小黑生活
喜茶学习完,准备练琴
怀柔马拉松出了参赛号码
练琴完吃个烤冷面
小汤3《牛仔之歌》打卡
上午参加婚礼
花了300元报了一个半程和一个全程,要攒钱啊,路费酒店费![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/175b5c01967c1916282db1199395a3fd.png)
来个咖啡醒醒酒
准备回姥姥家看一下店
去怀柔的火车票去程也买好了
边看店边刷题
晚饭家里来个铜锅