3 ms·
Very interesting that the 3 answers here are 2 Python and 1 C++; I feared the world had descended into a JS downward spiral, but clearly not.
by alexchamberlain 11y ago
Very interesting that the 3 answers here are 2 Python and 1 C++; I feared the world had descended into a JS downward spiral, but clearly not.
- TN1ck 11y agoI am your fear: var invertTree = function(root) { if (!root) { return root; } var left = root.left; var right = root.right; root.right = invertTree(left); root.left = invertTree(right); return root; };
- andresmanz 11y agoThat was my fear, too. And I also will go with C++ first.