This commit is contained in:
2025-09-15 21:12:04 +08:00
commit 3f58f483ff
144 changed files with 5298 additions and 0 deletions

32
24/04/1379.cpp Normal file
View File

@@ -0,0 +1,32 @@
//
// Created by szh2 on 24-4-3.
//
#include <iostream>
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
class Solution{
public:
TreeNode * getTargetCopy(TreeNode * original, TreeNode * cloned, TreeNode * target) {
if (original == nullptr) {
return nullptr;
}
if (original == target) {
return cloned;
}
TreeNode *left = getTargetCopy(original->left, cloned->left, target);
if (left != nullptr) {
return left;
}
return getTargetCopy(original->right, cloned->right, target);
}
};