1305:https://leetcode-cn.com/problems/all-elements-in-two-binary-search-trees/
题目:

思路:先中序遍历,再用Merge函数合并。
代码:

收获:merge(v1.begin(),v1.end(),v2.begin(),v2.end(),v3,compare);v3为结果集,compare可不写,则默认为升序排列
本文详细解析了LeetCode上的1305题——两个二叉搜索树的所有元素,介绍了通过中序遍历获取元素,再使用C++标准库函数merge进行有序集合合并的方法。分享了代码实现细节及技巧。
1305:https://leetcode-cn.com/problems/all-elements-in-two-binary-search-trees/
题目:

思路:先中序遍历,再用Merge函数合并。
代码:

收获:merge(v1.begin(),v1.end(),v2.begin(),v2.end(),v3,compare);v3为结果集,compare可不写,则默认为升序排列

被折叠的 条评论
为什么被折叠?