xinyu04

导航

2022年7月19日 #

LeetCode 56 Merge Intervals 排序+模板

摘要: Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals 阅读全文

posted @ 2022-07-19 21:42 Blackzxy 阅读(20) 评论(0) 推荐(0) 编辑

LeetCode 19 Remove Nth Node From End of List 链表节点删除+双指针

摘要: Given the head of a linked list, remove the $n$-th node from the end of the list and return its head. Solution 首先在原链表开头设置新头节点,然后先用 $fast$ 指针移动 $n$ 个单位 阅读全文

posted @ 2022-07-19 17:06 Blackzxy 阅读(11) 评论(0) 推荐(0) 编辑

LeetCode 226 Invert Binary Tree DFS

摘要: Given the root of a binary tree, invert the tree, and return its root. Solution: 直接使用 $DFS$ 进行递归即可: 点击查看代码 /** * Definition for a binary tree node. * 阅读全文

posted @ 2022-07-19 04:13 Blackzxy 阅读(12) 评论(0) 推荐(0) 编辑

[Google] LeetCode 366 Find Leaves of Binary Tree 思维+DFS

摘要: Given the root of a binary tree, collect a tree's nodes as if you were doing this: Collect all the leaf nodes. Remove all the leaf nodes. Repeat until 阅读全文

posted @ 2022-07-19 02:57 Blackzxy 阅读(14) 评论(0) 推荐(0) 编辑