Перейти к содержимому

شرح LeetCode 572 - Subtree of Another Tree

Debugger Dude

0:00 / 0:00

شرح LeetCode 572 - Subtree of Another Tree

26 просмотров · 10 мес. назад
Debugger Dude
109 подписчиков
26 просмотров · 10 мес. назад
Subtree of Another Tree Using C++ Time Complexity = O(N × M) because for each of the N nodes in root, we might check all M nodes in subRoot using isSameTree. Worst case happens when many nodes match and we compare the full subtree each time. (it can be reduced to O(N + M)) Try To Do IT ! Space complexity: O(N + M)