摘要: 解题思路: 首先构造一个节点slownode,它的next引用给定链表的头结点的地址。 之后把slownode赋值给fastnode。 将fastnode往前移动n步, 再将fastnode和slownode一起往前移动,直到fastnode移到最后一个位置。 class ListNode(obje 阅读全文
posted @ 2021-09-10 18:26 luckie 阅读(53) 评论(0) 推荐(0)
摘要: 解法一:暴力法 class Solution(object): def maxArea(self, height): """ :type height: List[int] :rtype: int """ lst=[] l=len(height) for i in range(l-1): for j 阅读全文
posted @ 2021-09-07 20:44 luckie 阅读(95) 评论(0) 推荐(0)
摘要: 知识点 sum(cost) over(PARTITION BY NAME ORDER BY p_date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS sample4,--和sample3一样,由起点到当前行的聚合 sum(cost) ov 阅读全文
posted @ 2021-08-12 18:12 luckie 阅读(223) 评论(0) 推荐(0)
摘要: 方法一:自连接(我自己想到的) # select a.employee_id # from Employees a # left join Employees b # on a.manager_id=b.employee_id # left join Employees c # on b.manag 阅读全文
posted @ 2021-08-10 16:24 luckie 阅读(351) 评论(0) 推荐(0)
摘要: 方法一:我自己写的 # with t as # ( # select * # ,case when host_goals>guest_goals then 3 when host_goals=guest_goals then 1 else 0 end as host_score, # case wh 阅读全文
posted @ 2021-08-09 16:35 luckie 阅读(207) 评论(0) 推荐(0)
摘要: 方法一 select round(sum(case when order_date=customer_pref_delivery_date then 1 else 0 end)/count(*)*100,2) immediate_percentage from Delivery; 方法二 selec 阅读全文
posted @ 2021-08-04 16:22 luckie 阅读(551) 评论(0) 推荐(0)
摘要: 理解题目意思很重要,化繁为简的能力很重要。 题目意思中暗含Customer表中的product_key来自于Product表中的product_key。 注意:Customer表中同一个customer_id,product_key可以重复。Product表中的product_key也可以重复。因为 阅读全文
posted @ 2021-06-29 21:23 luckie 阅读(502) 评论(0) 推荐(0)
摘要: 这道题很数学,需要转个弯。 方法一:使用case when后,如果学生人数是奇数,则改变了最后一个同学的座位。这时我们需要使用窗口函数重新进行一次排序。 select row_number() over (order by new_id) id,student from ( select case 阅读全文
posted @ 2021-06-29 20:58 luckie 阅读(268) 评论(0) 推荐(0)
摘要: 做这道题,我的感受是,大体思路是对的,但是由于对于题目意识的理解不够清楚,细节上容易出错。 select round(avg(average)*100,2) average_daily_percent from ( select a.action_date,ifnull(part_count,0)/ 阅读全文
posted @ 2021-06-29 20:11 luckie 阅读(487) 评论(0) 推荐(0)
摘要: 方法一: select product_id,product_name from ( select a.product_id,product_name, case when sale_date<='2019-03-31' and sale_date>='2019-01-01' then 0 else 阅读全文
posted @ 2021-06-27 21:30 luckie 阅读(105) 评论(0) 推荐(0)