摘要: 605. 种花问题 - 力扣(Leetcode) 下面是中间有0的情况下,可以种植的个数 1 0 2 0 3 1 4 1 5 2 6 2 7 3 8 3 9 4 两边边界问题,左边我使用 begin 往后挪了两位后认为是1,右边往右挪了两位后算作1 func canPlaceFlowers(flow 阅读全文
posted @ 2023-01-01 21:27 吴丹阳-V 阅读(36) 评论(0) 推荐(0)
摘要: 599. 两个列表的最小索引总和 - 力扣(Leetcode) 刚开始的思路是搞两个map,但是性能比较差,只需要构建一个map然后遍历第二个list即可 [!添加后可以过滤一些肯定不符合条件的] if k1 > indexSum { continue } func findRestaurant(l 阅读全文
posted @ 2023-01-01 17:12 吴丹阳-V 阅读(19) 评论(0) 推荐(0)
摘要: 598. 范围求和 II - 力扣(Leetcode) Go语言没有针对int的最小值、最大值以及比较算法,可以有一套,不然每次都需要写这个min函数 func maxCount(m int, n int, ops [][]int) int { if m <= 0 || n <= 0 { retur 阅读全文
posted @ 2023-01-01 16:38 吴丹阳-V 阅读(16) 评论(0) 推荐(0)
摘要: 595. 大的国家 - 力扣(Leetcode) 两种方法,一个是or一个是union,union会快一点 # Write your MySQL query statement below # select name, population, area from World # where area 阅读全文
posted @ 2023-01-01 14:27 吴丹阳-V 阅读(22) 评论(0) 推荐(0)
摘要: 594. 最长和谐子序列 - 力扣(Leetcode) 双指针,后面那个边界条件让我调了好几分钟 func findLHS(nums []int) int { sort.Ints(nums) left, right, maxLen := 0, 0, 0 for { if nums[right] - 阅读全文
posted @ 2023-01-01 13:46 吴丹阳-V 阅读(17) 评论(0) 推荐(0)
摘要: 590. N 叉树的后序遍历 - 力扣(Leetcode) 可以参考 [[leetcode-589. N 叉树的前序遍历]] ,代码差不多 /** * Definition for a Node. * type Node struct { * Val int * Children []*Node * 阅读全文
posted @ 2023-01-01 12:44 吴丹阳-V 阅读(23) 评论(0) 推荐(0)
摘要: 589. N 叉树的前序遍历 - 力扣(Leetcode) Go语言的切片操作方便性还不错 /** * Definition for a Node. * type Node struct { * Val int * Children []*Node * } */ func preorder(root 阅读全文
posted @ 2023-01-01 12:35 吴丹阳-V 阅读(14) 评论(0) 推荐(0)
摘要: 586. 订单最多的客户 - 力扣(Leetcode) # Write your MySQL query statement below select customer_number from ( select customer_number, count(*) cnt from Orders gr 阅读全文
posted @ 2023-01-01 12:03 吴丹阳-V 阅读(20) 评论(0) 推荐(0)
摘要: 584. 寻找用户推荐人 - 力扣(Leetcode) sql 题,还是比较简单的 # Write your MySQL query statement below select name from customer where referee_id <> 2 or referee_id is nu 阅读全文
posted @ 2023-01-01 11:40 吴丹阳-V 阅读(31) 评论(0) 推荐(0)
摘要: 575. 分糖果 - 力扣(Leetcode) 信息: 糖果的种类 总个数 吃一半 分析: 种类大于一半,那么只能吃一半 种类小于一半,那么是种类量 考哈希表,有点简单,熟悉Go语法还行 func distributeCandies(candyType []int) int { if len(can 阅读全文
posted @ 2023-01-01 01:24 吴丹阳-V 阅读(22) 评论(0) 推荐(0)