Find the corresponding node of a binary tree in the clone of that tree (Leetcode 1379)

Technique: FAITH technique of Recursion

Problem Link: https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/

class Solution:

    def getTargetCopy(self, original: TreeNode, cloned: TreeNode, target: TreeNode) -> TreeNode:
    
        if(original is None):
            return None
        if(original == target):
            return cloned
        l=self.getTargetCopy(original.left, cloned.left, target)
        if(l is not None):
            return l
        r=self.getTargetCopy(original.right, cloned.right, target)
        if(r is not None):
            return r
        return None

Last updated