摘要: 题目:【https://leetcode.cn/problems/unique-paths-ii/?envType=study-plan-v2&envId=top-interview-150】 下面这个深度优先搜索超时了。。。不过还是记录一下,看看自己失败在那里。。。 1 class Solutio 阅读全文
posted @ 2025-05-09 17:12 J&YANG 阅读(10) 评论(0) 推荐(0)
摘要: 归根结底还是要辅助空间,创建一个返回值的vector,另外sort可以直接排序这种复杂纯数据,即使是二维的,也会按照先第一维,然后第二维的顺序,排序正确。 题目:【https://leetcode.cn/problems/merge-intervals/description/?envType=st 阅读全文
posted @ 2025-05-09 16:13 J&YANG 阅读(5) 评论(0) 推荐(0)
摘要: 单链表真的遭罪,不过有一个技巧,就是创建一个head,这样便于处理首元素就需要删除的情况。 题目:【https://leetcode.cn/problems/remove-duplicates-from-sorted-list-ii/?envType=study-plan-v2&envId=top- 阅读全文
posted @ 2025-05-09 14:34 J&YANG 阅读(9) 评论(0) 推荐(0)
摘要: 题目用双指针方法很好想思路,只不过有一种情况要排除,就是链表元素数量==倒数n的时候,要在判断到快指针为NULL的时候,直接返回head->next,排除这种情况之后,其它情况就很好处理了。 题目:【https://leetcode.cn/problems/remove-nth-node-from- 阅读全文
posted @ 2025-05-09 10:10 J&YANG 阅读(12) 评论(0) 推荐(0)