< Summary

Information
Class: LeetCode.Algorithms.FindCorrespondingNodeOfBinaryTreeInCloneOfThatTree.FindCorrespondingNodeOfBinaryTreeInCloneOfThatTreeDepthFirstSearchRecursive
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\FindCorrespondingNodeOfBinaryTreeInCloneOfThatTree\FindCorrespondingNodeOfBinaryTreeInCloneOfThatTreeDepthFirstSearchRecursive.cs
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 44
Line coverage: 100%
Branch coverage
100%
Covered branches: 10
Total branches: 10
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetTargetCopy(...)100%1010100%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\FindCorrespondingNodeOfBinaryTreeInCloneOfThatTree\FindCorrespondingNodeOfBinaryTreeInCloneOfThatTreeDepthFirstSearchRecursive.cs

#LineLine coverage
 1// --------------------------------------------------------------------------------
 2// Copyright (C) 2025 Eugene Eremeev (also known as Yevhenii Yeriemeieiv).
 3// All Rights Reserved.
 4// --------------------------------------------------------------------------------
 5// This software is the confidential and proprietary information of Eugene Eremeev
 6// (also known as Yevhenii Yeriemeieiv) ("Confidential Information"). You shall not
 7// disclose such Confidential Information and shall use it only in accordance with
 8// the terms of the license agreement you entered into with Eugene Eremeev (also
 9// known as Yevhenii Yeriemeieiv).
 10// --------------------------------------------------------------------------------
 11
 12using LeetCode.Core.Models;
 13
 14namespace LeetCode.Algorithms.FindCorrespondingNodeOfBinaryTreeInCloneOfThatTree;
 15
 16/// <inheritdoc />
 17public class FindCorrespondingNodeOfBinaryTreeInCloneOfThatTreeDepthFirstSearchRecursive :
 18    IFindCorrespondingNodeOfBinaryTreeInCloneOfThatTree
 19{
 20    /// <summary>
 21    ///     Time complexity - O(n)
 22    ///     Space complexity - O(n) for a skewed tree, O(log n) for balanced tree
 23    /// </summary>
 24    /// <param name="original"></param>
 25    /// <param name="cloned"></param>
 26    /// <param name="target"></param>
 27    /// <returns></returns>
 28    public TreeNode? GetTargetCopy(TreeNode? original, TreeNode? cloned, TreeNode? target)
 1329    {
 1330        if (original == null || cloned == null || target == null)
 531        {
 532            return null;
 33        }
 34
 835        if (original.Equals(target))
 336        {
 337            return cloned;
 38        }
 39
 540        var node = GetTargetCopy(original.left, cloned.left, target);
 41
 542        return node ?? GetTargetCopy(original.right, cloned.right, target);
 1343    }
 44}