Home > Reflections | โฎ๏ธ โญ๏ธ
2024-07-07 | ๐ผ Job ๐ Search | ๐ช Symmetree ๐ฒ
๐ง Education
โณ๐ป๐ผ๐ฏ The 2-Hour Job Search: Using Technology to Get the Right Job Faster
๐ 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.