LeetCode Most Common Word Solution Explained - Java

  Рет қаралды 10,152

Nick White

Nick White

Күн бұрын

Пікірлер: 13
@cankaraman6529
@cankaraman6529 4 жыл бұрын
Nice video and thanks. But, i think the third loop is unnecessary because you can iterate the max value through second loop while getting "getOrDefault(..)" value -> if latest value is greater than max, then it is the max. i liked the video anyway, thanks for your effort.
@zzzppp-df9ex
@zzzppp-df9ex 5 жыл бұрын
Great videos Nick. I have been learning algorithms from your videos for long time. Thank you for making all these great videos.
@tire
@tire 4 жыл бұрын
I did my work with this video, thanks dude !
@shubhamkhurana7545
@shubhamkhurana7545 5 жыл бұрын
This is a great one Sir. Can you pls do a tutorial on "Top k frequent words" using map as well as heap approach. Thank you
@akhilp2009
@akhilp2009 2 жыл бұрын
one comment from my side - why you need a hashSet separately ? from the questions already 'banned words' are in list, so we can check List.Contains() - right? then we can reduce space complexity. what you say ?
@meepable
@meepable 4 жыл бұрын
What's the time complexity of your solution? From what I see, it's O(1) for result. two loops are (N) but not directly impacting the result itself. So is it O(1)? I checked the solution in leetcode and it's O(1), I thought it was O(N). And get well soon!
@tommyypoon
@tommyypoon 4 жыл бұрын
time complexity is O(m+n) m = amount of words in paragrpah, n = amount of words in banned
@alinal6852
@alinal6852 4 жыл бұрын
like your video!
@sujitamin949
@sujitamin949 4 жыл бұрын
CAMEL CASE BRO
@aishwaryamajumdar6927
@aishwaryamajumdar6927 4 жыл бұрын
String class is immutable. How are you able to assign value to it again and again in the last for loop? I have exactly the same solution but the output gives the whole paragraph appended to the result String. This solution is wrong.
@dileshsolanki2383
@dileshsolanki2383 4 жыл бұрын
@Aishwarya Majumdar He's not appending words, he's just assigning the word to max string or rather replacing each time. You might have written result+=word; instead of result=word; which might be causing you the problem.
@unknownman1
@unknownman1 4 жыл бұрын
@@dileshsolanki2383 Bro, she said that string classes are immutable which means you can't edit or do anything with it. And as you said "He's not appending words, he's just assigning the word to max string or rather replacing each time", assigning or replacing the word means the string is mutable, which is not possible.
@senathsadeesha4598
@senathsadeesha4598 3 жыл бұрын
Yes ,Strings are immutable , when the String get modified it stores the value in an another location of the String pool, however I think it creates extra number of objects. I prefer a String builder here and later on we can convert it to a String
LeetCode Verifying an Alien Dictionary Solution Explained - Java
11:17
LeetCode Next Greater Element I Solution Explained - Java
9:51
Nick White
Рет қаралды 34 М.
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,1 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 10 МЛН
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 13 МЛН
Thank you Santa
00:13
Nadir Show
Рет қаралды 59 МЛН
Integer to English Words - Leetcode 273 - Python
20:59
NeetCodeIO
Рет қаралды 15 М.
This Algorithm is 1,606,240% FASTER
13:31
ThePrimeagen
Рет қаралды 855 М.
LeetCode Buddy Strings Solution Explained - Java
9:21
Nick White
Рет қаралды 10 М.
10 years of coding in 13 minutes
13:28
Joma Tech
Рет қаралды 4,9 МЛН
I Solved 1583 Leetcode Questions  Here's What I Learned
20:37
ThePrimeTime
Рет қаралды 754 М.
Self Taught Programmers... Listen Up.
11:21
Nick White
Рет қаралды 1,1 МЛН
If You're So Smart, Why Aren't You Rich?
20:20
Damien Talks Money
Рет қаралды 386 М.
LeetCode 290. Word Pattern Solution Explained - Java
8:58
Nick White
Рет қаралды 15 М.
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,1 МЛН