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-df9ex5 жыл бұрын
Great videos Nick. I have been learning algorithms from your videos for long time. Thank you for making all these great videos.
@tire4 жыл бұрын
I did my work with this video, thanks dude !
@shubhamkhurana75455 жыл бұрын
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
@akhilp20092 жыл бұрын
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 ?
@meepable4 жыл бұрын
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!
@tommyypoon4 жыл бұрын
time complexity is O(m+n) m = amount of words in paragrpah, n = amount of words in banned
@alinal68524 жыл бұрын
like your video!
@sujitamin9494 жыл бұрын
CAMEL CASE BRO
@aishwaryamajumdar69274 жыл бұрын
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.
@dileshsolanki23834 жыл бұрын
@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.
@unknownman14 жыл бұрын
@@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.
@senathsadeesha45983 жыл бұрын
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