Created
April 2, 2021 14:24
-
-
Save vanbrabantf/3b0b799543d5944786184712d7c8a3a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function invert(?Node $tree): ?Node | |
{ | |
if ($tree === null) { | |
return null; | |
} | |
$right = $this->invert($tree->getLeft()); | |
$left = $this->invert($tree->getRight()); | |
return new Node($tree->getValue(), $left, $right); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment