4085. Find Root of a Colored Tree | LeetCode Weekly Contest 524 | O(N) Optimal Approach
RealGuideBhai
0:00 / 0:00
4085. Find Root of a Colored Tree | LeetCode Weekly Contest 524 | O(N) Optimal Approach
401 просмотр · 2 нед. назад
RealGuideBhai
91 подписчик
401 просмотр · 2 нед. назад
Welcome to @RealGuideBhai In this video, we solve "Find Root of a Colored Tree" from LeetCode Weekly Contest 524. We avoid the O(N^2) TLE trap and solve it in optimal O(N) time by using the strict (R - B - W) color sequence to convert the undirected tree into a directed graph.
Timestamps:
00:00 - Problem Statement
02:39 - Problem Understanding
03:25 - Brute Force O(N^2)
04:50 - Optimal Approach
05:35 - Is multi Roots possible ??
08:25 - Finding Single root
09:48 - Binary property
10:19 - Find next node
11:29 - Code Implementation
13:58 - Multi Roots ??
15:22 - The Hidden Binary Tree Constraint
17:03 - Manual write vs Pre written ??
If you found this logic helpful, please LIKE and SUBSCRIBE to @RealGuideBhai for more competitive programming solutions!
Tags: #LeetCode #LeetCode524 #FindRootOfAColoredTree #DSA #CPP #CompetitiveProgramming #RealGuideBhai