hey neetcode, just want to let you know that I got an offer from a FAANG company after months of rigorously going through problems and watching your vids to clear up confusion when I got stuck. Personally I found that your explanations are the best, you don't just talk code but you talk about the underlying concepts (and explaining them with clear drawings are a HUGE BONUS) which most of other youtubers kind of skip. I can't thank you enough, keep up the good work! Your work will help many people I am so sure of it. I still have another set of interview with another FAANG company, hopefully I'll whichever company I'll end up with will be the best choice. So you bet I will still grind your vids for the foreseeable future (and onwards of course). Cheers!
There are no words to tell how beautifully u put these videos so simple. Finally got a decent product job. I would love to watch neetcode even if I grow older ❤. Keep posting the videos
If I get a job in the future..... It's 100 percent because of NeetCode! Thank you So much and Congratulations for 100k subscribers You deserve it because you have the best video explanations on the entire internet....btw this is probably the Easiest Hard problem I've ever seen
@@simonbabatunde4333 I solved it before the video dropped because it was a daily challenge problem for March 19th. I can see why it can look complicated ...... the first thing that comes to mind is to use heaps.... but the simplest way turned out to be the optimal solution. I'm pretty sure I've seen a similar problem before.
@@NeetCode how long did it take you?…starting this interview questions journey myself…feels dreadful. What do you think of first whenever you face a problem that looks impossible to solve? What one thing do you always do in yr thinking approach to these questions?
@@Colls-m8i if you'll practice coding regularly just 3 hours each day for like 6-7 months. You gonna ace normal startup interviews and if you'll continue so for next 9-12 months. You'll ace good product based company easily. Not sure about Google but definitely a good company. I just got a job in Adobe.
Man how do you keep up uploading these even while working at google. But good job keep up the good work, I'm still trying one day I may also pass the google interview.
I don't think you need to keep track of the maximum. A frequency can only ever be incremented (increased by one). Thus the maximum frequency can only ever rise by one. Thus it is enough to keep an array, indexed by frequency-1. Its size is then the maximum frequency.
Hello NeetCode, Thank you for your great work. I’m just curious about what software you are using for drawing explanations and screen recording because I need to make the same kind of videos for my friends.
@@NeetCode thank you very much. The streaming software is what I’ve never come up is. I appreciate it. Just fyi I was surprised that you’re using Windows instead of Mac
I need a confirmation from you on height vs depth of a binary tree...for the height the base condition is "if not root: return -1" and for depth it is "return 0" right ?? when you search on google for height of a binary tree you will see both cases as valid answer...i am a bit confused could you please answer this. Height of null tree is -1, height of a single node is 0, right ?
Hi man, I really like your video.. Unfortunately, I got rejection letter from Google yesterday.. Now I am really frustrating. :( Even I solved the problem during interview..
When you ever stuck in a problem just throw a hashmap 😄
Agree😁
hey neetcode, just want to let you know that I got an offer from a FAANG company after months of rigorously going through problems and watching your vids to clear up confusion when I got stuck. Personally I found that your explanations are the best, you don't just talk code but you talk about the underlying concepts (and explaining them with clear drawings are a HUGE BONUS) which most of other youtubers kind of skip. I can't thank you enough, keep up the good work! Your work will help many people I am so sure of it. I still have another set of interview with another FAANG company, hopefully I'll whichever company I'll end up with will be the best choice. So you bet I will still grind your vids for the foreseeable future (and onwards of course). Cheers!
what was your language of choice
Took about 1.5 months to walkthrough all your Coding Interview Solutions playlist. I really appreciate for all your works!
Simplified a little bit :
import collections
class FreqStack:
def __init__(self):
self.count = {}
self.groups = collections.defaultdict(list)
def push(self, val):
self.count[val] = self.count.get(val, 0) + 1
self.groups[self.count[val]].append(val)
def pop(self):
result = self.groups[max(self.groups.keys())].pop()
self.count[result] -= 1
if self.groups[max(self.groups.keys())] == []:
self.groups.pop(max(self.groups.keys()))
return result
There are no words to tell how beautifully u put these videos so simple. Finally got a decent product job. I would love to watch neetcode even if I grow older ❤. Keep posting the videos
You make me fall in love with Coding!
Many many thanks :)
Keep up the good work please ;p
Thanks Neetcode for making this problem simpler for me!
I always feel released when I got stuck in a problem but found out that you have posted a video solution on it. Thanks NeetCode!! Keep going!!!!
If I get a job in the future..... It's 100 percent because of NeetCode! Thank you So much and Congratulations for 100k subscribers You deserve it because you have the best video explanations on the entire internet....btw this is probably the Easiest Hard problem I've ever seen
"Easiest hard problem" because it's been solved already. You can only say that if you sit at it to implement yourself.
@@simonbabatunde4333 I solved it before the video dropped because it was a daily challenge problem for March 19th. I can see why it can look complicated ...... the first thing that comes to mind is to use heaps.... but the simplest way turned out to be the optimal solution. I'm pretty sure I've seen a similar problem before.
I found the similar problem from my spreadsheet. 347. Top K Frequent Elements.
me as an unemployee year 3 day 25. amazing video. i wonder how long it will take a job at fang
i know you'll make it buddy 🥲
@@NeetCode how long did it take you?…starting this interview questions journey myself…feels dreadful. What do you think of first whenever you face a problem that looks impossible to solve? What one thing do you always do in yr thinking approach to these questions?
@@Colls-m8i if you'll practice coding regularly just 3 hours each day for like 6-7 months. You gonna ace normal startup interviews and if you'll continue so for next 9-12 months. You'll ace good product based company easily. Not sure about Google but definitely a good company. I just got a job in Adobe.
This one idea of maintaining stack ( stack = valcnt : [1,2,3] ) saved me. Thanks great solution
Man how do you keep up uploading these even while working at google. But good job keep up the good work, I'm still trying one day I may also pass the google interview.
Thanks a lot for such a great explanation. Love from India ♥
neetcode is like the rachel maddow of all tech youtubers...... best explainer everrrrrrr...
Dude !!! You are a leetcode GOD !!!! Fantastic visual explanation and code. Thanks !
there is something between this problem and a Young Tableux now that the final structure is revealed to be this stack of lists of decreasing heights.
I like this one where you focus on the thought process to find the solution
I don't think you need to keep track of the maximum. A frequency can only ever be incremented (increased by one). Thus the maximum frequency can only ever rise by one. Thus it is enough to keep an array, indexed by frequency-1. Its size is then the maximum frequency.
Wow, Now you're in the Daily Challenge. Thank you for great video
My implementation, I find it one more intuitive :)
---------------------------------------------------------
class FreqStack:
def __init__(self):
self.c = count(0)
self.pq = []
self.freq = defaultdict(int)
def push(self, data):
self.freq[data] += 1
heapq.heappush(self.pq, (-self.freq[data], -next(self.c), data))
def pop(self):
while self.pq:
_, _, d = heapq.heappop(self.pq)
self.freq[d] -= 1
return d
raise KeyError("pop from empty cache")
wow thats a really creative solution
HashMap is jack of all trades.
Heap will work, just keep the heap index of a valand update its freq and do top to bottom and bottom to top...
Can you take a look at some of the questions that Meta gives on their career pages?
Hello NeetCode, Thank you for your great work. I’m just curious about what software you are using for drawing explanations and screen recording because I need to make the same kind of videos for my friends.
I use Paint3D with a mouse, and Streamlabs OBS for screen recording.
@@NeetCode thank you very much. The streaming software is what I’ve never come up is. I appreciate it. Just fyi I was surprised that you’re using Windows instead of Mac
Yes, thought of the heap solution n(log n) -> O(n^2) worst case :(
Enjoyable problem and nice explanation!
superb explanation
Perfect explanation
Very good solution
bro also share tips to prep for faang from where to do word problems to clear first round
What shortcut did you use to change stack to stacks ? I am able to do the multi-cursor operation in vscode but not in stackoverflow editor
You are awesome man!
What do you think about AlphaCode?
Just copped that Patreon 10 pack fam. It's peanuts next to your Google salary but enjoy a coffee on me
Thank you so much!!! I really appreciate it!
Thanks for the help mate
I need a confirmation from you on height vs depth of a binary tree...for the height the base condition is "if not root: return -1" and for depth it is "return 0" right ?? when you search on google for height of a binary tree you will see both cases as valid answer...i am a bit confused could you please answer this. Height of null tree is -1, height of a single node is 0, right ?
Sir Please make videos java problems
Hi man, I really like your video.. Unfortunately, I got rejection letter from Google yesterday.. Now I am really frustrating. :( Even I solved the problem during interview..
I just wanted to say THANKS!
Was it the phone interview?
@@nguessaneric9830 No, The first round of coding interview
Very smart 👏👏
What projects did u put while applying for job interview at google
OHHHHHH, WOWWWWWWW