Delete Nodes And Return Forest| Leetcode 1110 in Java | Must do Tree Questions |Google DSA Interview
Автор: Code Thoughts
Загружено: 2024-07-17
Просмотров: 99
Описание:
In this question its Given the root of a binary tree, each node in the tree has a distinct value.
After deleting all nodes with a value in to_delete, we are left with a forest (a disjoint union of trees).
Return the roots of the trees in the remaining forest. You may return the result in any order.
My Approach is very simple, i am using a bottom up recursive approach, i am converting the to_delete array to an Set so that search would be faster, so the resursive approach is in such a way that it will modify the Tree on left and right sub tree and also return whatever would be the value and we would then checking if the root itself also in the list of to_delete set then we would add both left and right non-null values to the Answer list. this recursive approach is then used to main function and updated the final ans list.
DSA Algorithms :-
• Topological sorting in Hindi | Topological...
Design HLD:-
• Design E-commerce website | Design Amazon ...
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview #interviewtips
#interviewpreparation #interview_ds_algo #hinglish
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: