题目链接 解题思路: 使用层序遍历,输出每一层最右边的节点即可。 C++: /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * T Read More
题目链接 解题思路: 迭代C++: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * Read More
题目链接 解题思路: 直接上代码: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * Read More