LeetCode 501. Find Mode in Binary Search Tree (Algorithm Explained)

preview_player
Показать описание


Preparing For Your Coding Interviews? Use These Resources
————————————————————

Other Social Media
----------------------------------------------

Show Support
------------------------------------------------------------------------------

#coding #programming #softwareengineering
Рекомендации по теме
Комментарии
Автор

Thanku so much, i always used to think that these high rated coders will just make the problem more harder instead of explaining simply, but you proved it wrong

vinayjangra
Автор

1:20, thanks a lot for writing like this. I got the logic that inorder traversal can be used. And solved it right away.

sadmanabedin
Автор

Very fresh solution, btw what is the extension you used on chrome to get the dropdown selection just like were in the ide ?, that sick!

neonanh
Автор

Thanks for sharing!! It is one of the tough questions and very less explanations with O(1) space complexity..

ankitagarwal
Автор

It's funny how Nick hates saying the mundane intro

xedb
Автор

It feels ugly to put the max and prev as class members. Feel like they should be parameters of the traverse function.

cunningham.s_law
Автор

Nick you are good at this. Just take it a little slow when explaining

thomasfrimpong
Автор

u did not consider a condition for the case where there are multiple modes and if it does exists in the list already!? 'cause that will give error!!

aditisharma
Автор

It's okay to make mistakes. Love the explanation. Good stuff

lifeofme
Автор

SDU top, AND this man actually top top

ramazankhakimzhan
Автор

def not an easy question if you do it with O(1) space

divijjain
Автор

the intro gave me very big cocaine vibes lol

QEats
Автор

explanation incomplete please explain inorder succesor and predecessor

sharangkulkarni
Автор

what if you have after 30 to left 25? it will be 30->25->20, would your algorithm work please?

mohammadyahya
Автор

For anyone watching, you can change the last four lines of code in the findMode method to:
return modes.toArray(new int[modes.size()]);

joecamroberon
Автор

Gosh Nick you're really cranky in this vid LOL

Revitalish
Автор

using the names of the variables as freq and maxFreq will make more sense here instead of count and max

g_
Автор

Hey Why did you declared prev as Integer instead of primitive type

chiragchatwani
Автор

Pass an array with every node, for every node insert the node value in the array. Inside main, sort the array and find the mode.

sounavapal
Автор

i think this will fail for [1, null, 2] input, it give output [2] but the output should be [1, 2] ... also need to add this check before prev != null ....

if (prev == null && modeCount == 0) {
modeCount = 1;
}

omkarnath
welcome to shbcf.ru