题目链接 解题思路: 使用层序遍历,输出每一层最右边的节点即可。 C++: /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * T Read More
posted @ 2021-04-02 15:46 洗盏更酌 Views(68) Comments(0) Diggs(0) Edit
题目链接 解题思路: 迭代C++: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * Read More
posted @ 2021-04-02 10:51 洗盏更酌 Views(37) Comments(0) Diggs(0) Edit
题目链接 解题思路: 直接上代码: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * Read More
posted @ 2021-04-02 00:48 洗盏更酌 Views(71) Comments(0) Diggs(0) Edit