Home > Reflections | โฎ๏ธ โญ๏ธ

2024-07-07 | ๐Ÿ’ผ Job ๐Ÿ” Search | ๐Ÿชž Symmetree ๐ŸŒฒ

๐Ÿง  Education

โณ The 2-Hour Job Search

๐Ÿ‹ Coding Practice

Previously, I solved the LeetCode 101.ย Symmetric Tree.
On my first attempt, I actually failed to solve the problem, attempting an approach that didnโ€™t work out.
Last time, I did implement a working solution, but it felt like more work than was necessary.
Today, I looked up the official solution, and see that they demonstrate a recursive approach that I hadnโ€™t identified.
I find this approach interesting, because their isMirror function is nearly identical to the equal function I implemented as a helper in my working solution.
I struggled to find a recursive solution that directly solves the problem because I wasnโ€™t able to see how we could keep track of both sides of the tree independently as we recursively descend.
I see that they solved this by creating an isMirror function that takes 2 trees, and descends each one recursively.