Тёмный

LeetCode Binary Tree Right Side View Explained - Java 

Nick White
Подписаться 386 тыс.
Просмотров 16 тыс.
50% 1

The Best Place To Learn Anything Coding Related - bit.ly/3MFZLIZ
Join my free exclusive community built to empower programmers! - www.skool.com/...
Preparing For Your Coding Interviews? Use These Resources
--------------------
(My Course) Data Structures & Algorithms for Coding Interviews - thedailybyte.d...
AlgoCademy - algocademy.com...
Daily Coding Interview Questions - bit.ly/3xw1Sqz
10% Off Of The Best Web Hosting! - hostinger.com/...
Follow Me on X/Twitter - x.com/nickwhit...
Follow My Instagram - / nickwwhite
Other Social Media
----------------------------------------------
Discord - / discord
Twitch - / nickwhitettv
TikTok - / nickwhitetiktok
LinkedIn - / nicholas-w-white
Show Support
------------------------------------------------------------------------------
Patreon - / nick_white
PayPal - paypal.me/nick....
Become A Member - / @nickwhite
#coding #programming #softwareengineering

Опубликовано:

 

20 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 21   
@siddhantmisra5664
@siddhantmisra5664 5 лет назад
I loved this solution. I went through so many solutions and some of them were so weird to understand. Thank you for this. Just put it in 1.5x to get through it quicker and still understood it better than most of the solutions out there.
@neelakshsharma4936
@neelakshsharma4936 4 года назад
Amazing solution. Thanks to the OP and Nick White for explaining it in an elegant manner.
@Tech_Hub855
@Tech_Hub855 3 года назад
class Solution { List list; public List rightSideView(TreeNode root) { list = new ArrayList(); rightTraversal(root,0); return list; } void rightTraversal(TreeNode node, int level){ if(node == null) return; if(list.size() ==level) list.add(level,node.val); rightTraversal(node.right,level+1); rightTraversal(node.left,level+1); } }
@liveLifeHappyFull
@liveLifeHappyFull 4 года назад
I am in love with this solution!!!! Thank you Nick!!!
@VinayKumar-xs6el
@VinayKumar-xs6el 7 месяцев назад
see in level order traversal loop runs from left to right so we have to take out only values that equals size-1 dont know why it worked for you even u specified i==0 which is left most node
@funnyhjk
@funnyhjk 4 года назад
Beautiful solution! Big fan of your leetcode videos, especially because you're so clear and concise with your explanations. Thanks bro!
@navneet1679
@navneet1679 Год назад
This is just best! Smart and Simple.
@anonofDeath
@anonofDeath 2 года назад
How does the right side of the contents get inputted into result? I am missing something and I can't find it out.
@surajgrandhi6742
@surajgrandhi6742 4 года назад
Amazing explanation nick
@apughose5919
@apughose5919 4 года назад
What is the Time complexity? I am just confused. Is it O(n^2) as it is running the Queue twice?
@rahuldabas8233
@rahuldabas8233 4 года назад
what changes we have to do to make it left side view of tree
@saicharan1000
@saicharan1000 2 года назад
Pass the left node first instead of the right node, like a normal level order BFS.
@TheProximator
@TheProximator 3 года назад
what happens if there are only left nodes in the tree? would it work too?
@iamNirbhaymishra
@iamNirbhaymishra 3 года назад
Good solution
@anuragmishra2964
@anuragmishra2964 4 года назад
thank you Nick!
@rupaldesai7098
@rupaldesai7098 5 лет назад
Not as optimal as BFS/ DFS
@liveLifeHappyFull
@liveLifeHappyFull 4 года назад
This is BFS but taking the right node first
@Tech_Hub855
@Tech_Hub855 3 года назад
Hey what about this way class Solution { List list; public List rightSideView(TreeNode root) { list = new ArrayList(); rightTraversal(root,0); return list; } void rightTraversal(TreeNode node, int level){ if(node == null) return; if(list.size() ==level) list.add(level,node.val); rightTraversal(node.right,level+1); rightTraversal(node.left,level+1); } }
@avinashpatil5572
@avinashpatil5572 6 месяцев назад
Done
@chaoschao9432
@chaoschao9432 4 года назад
i think this is bfs.
@robinjaison8947
@robinjaison8947 3 года назад
💯
Далее
Борщ в стиле высокой кухни!
00:57
Self Taught Programmers... Listen Up.
11:21
Просмотров 1,1 млн
I Got Rejected (again)
9:43
Просмотров 205 тыс.
I Solved 1583 Leetcode Questions  Here's What I Learned
20:37
Coding Was Hard Until I Learned THESE 5 Things!
8:02
Binary Trees - Data Structures Explained
10:18
Просмотров 132 тыс.
How I Coded An Entire Game Using ChatGPT
19:48
Просмотров 121 тыс.
The hidden beauty of the A* algorithm
19:22
Просмотров 874 тыс.
Борщ в стиле высокой кухни!
00:57