vector<int> getAllElements(TreeNode* root1, TreeNode* root2) {
getAllElements(root1, left);
getAllElements(root2, right);
int len = left.size() + right.size();
if (len == 0) return vector<int>();
while(i < left.size() && j < right.size()) {
if (left[i] < right[j]) vec[k++] = left[i++];
else vec[k++] = right[j++];
while(i < left.size()) vec[k++] = left[i++];
while(j < right.size()) vec[k++] = right[j++];
void getAllElements(TreeNode *root, vector<int> &vec) {
if (root == nullptr) return ;
while(root || !st.empty()) {
root = st.top(); st.pop();
vec.push_back(root->val);