How To Solve '100 Same Tree' on LeetCode - JavaScript Easy

preview_player
Показать описание
Do you need more help with coding?
════════════════════════════

Problem: 100 Same Tree
Language: Javascript
Difficulty: Easy

This is only one possible solution and may not be the most optimal.

Pseudo Code:

1. If p and q are both null, return true
2. If p is null while q isn't OR q is null while p isn't OR vals are not the same, return false
3. Return isSameTree(left for both) and is SameTree(right for both)

Time Complexity: O(n)
Space Complexity : O(n)
where n is the shortest number of nodes between q and p

Let's Connect 💯:
════════════════════════════
Рекомендации по теме
Комментарии
Автор

Thank you for the clear explanation!! Things are certainly starting to stick for me.

johnsoto
welcome to shbcf.ru