Slick & straight! Thank you for breaking the complexity.
@sheldoncooper7990 Жыл бұрын
You the one of the best here on KZbin, the way you teach, the way you keep every in a structured manner is super commendable. Subscribed.
@nikoo28 Жыл бұрын
thanks for the kind words
@michaelagedie94339 ай бұрын
Keep making these videos bro, the quality is Amazing!
@Rits2203 Жыл бұрын
You've explained in a very simple way!!
@palanivelraju1981 Жыл бұрын
there's a small mistake in the dry run in moore's algo at last votes for majority 2 is 1,when majority reaches 3 the votes will be 0, so, majority will be updated in the next iteration so majority will be update as 1, please check, explanation is too good!!!
@nikoo28 Жыл бұрын
the dry-run is mainly to understand the simplicity of the code. The exact working code is available in the description too. Mostly you should understand the approach and how you are solving the problem :)
@Ramu_Sriram9 ай бұрын
Bro, the quality of your content is exceptional. You deserve more subscribers. Thank you brother.
@nikoo288 ай бұрын
I wish that too 😄
@ayushijindal4898 Жыл бұрын
Beautifully Explained
@negxativexd262210 ай бұрын
After watching 5 videos finally understood ... kaafi acchaa explanation...loved it
@nikoo289 ай бұрын
Thanks for liking
@hameedmulani21 Жыл бұрын
Superb Explanation!
@nikoo28 Жыл бұрын
Thank you 🙂
@tng31008 ай бұрын
the second soln was impressive,
@MythBuster28_108 ай бұрын
Glad i found your channel
@m.abrarsheikh98655 ай бұрын
Next level & Awesome explaination with cutest smile. Thank you😊
@nikoo284 ай бұрын
that is so sweet of you
@SaniyaThrisha10 ай бұрын
this was very helpful 😀 Thank you
@satyamgupta6030 Жыл бұрын
great solution as always. Thanks alot bhaiya please keep on making such amazing videos.
@nikoo28 Жыл бұрын
So nice of you
@velocity11864 ай бұрын
Your teaching is superb. You have a new subscriber.
@nikoo284 ай бұрын
Thanks a lot 😊
@marcelocarvalholopes9 ай бұрын
Thank you. Very good explanation!
@akhintheruvath3 ай бұрын
Thanks for this great explanation
@amanverma8258 Жыл бұрын
Thanks a lot sir ! Really helpful
@SandipKumarRoy12 Жыл бұрын
Awesome explanation 😮😮
@Hello-l3i4 ай бұрын
pls make a video on peak element ... your videos are so helpful!!!!
@kunalkheeva Жыл бұрын
thank you, your dry run really helped
@LalitSingh-nd5vx9 ай бұрын
better explanation than Striver .
@riddle_cicad0078 ай бұрын
Great video, you explained it so well. Thanks !!
@rakeshbabu38393 ай бұрын
Amazing exaplanation
@bhumikabansal6022 Жыл бұрын
SO CLASSY AND please make the playlist of data structures important questions too
Great video man! Loved this explanation, you are highly underrated. If it's possible can you do python solutions as well for future leetcode videos? Thanks again!
@nikoo28 Жыл бұрын
i would advice you to focus on the problem solving method, rather than the language. Trust me...languages will come and go...get your basics right first :)
@shubhammanecr7 Жыл бұрын
Amazing!
@CelestialEditzHub Жыл бұрын
Amazing great explanation
@ahmedbaig854310 ай бұрын
Very Well Explained
@nikoo2810 ай бұрын
Thank you so much 🙂
@ajaykumar-yk7to Жыл бұрын
super sir good explanation
@arnavkukreti2009 Жыл бұрын
perfect teacher
@nikoo28 Жыл бұрын
perfect student :)
@albingeorgekurian43963 ай бұрын
it's tough to get an optimized solution 😔.... but I will try to reach it on my own 😊.
@snehaaggarwal76202 ай бұрын
sir in moore algo we take example as 3383372150987216 then 3 is not majority according to that or how to solve that
@mdjabedansari456126 күн бұрын
votes suhuld be initialised to 0 at start please correct that or mention that in the description
@CSstudent_1001 Жыл бұрын
LEGEND 🖤
@SMARTRIXDbztttmods Жыл бұрын
*Sir Please Complete top 150 interview Questions First from Leetcode 🔥*
@nikoo28 Жыл бұрын
there are some problems from that list that I have covered...adding new solutions every week :)
@SMARTRIXDbztttmods Жыл бұрын
@@nikoo28 *Thankyou Sir Loved your teaching Very Clear & Upto the point*
@hameedmulani21 Жыл бұрын
@@nikoo28 thank you!
@hameedmulani21 Жыл бұрын
You're the best👍💯
@nikoo28 Жыл бұрын
You are!
@snehaaggarwal76202 ай бұрын
sir in optimization in sorting if we have 1234567889 then 8 is not centered how?
@AzidzogiDizoАй бұрын
I guess because the number of eights must satisfy this condition: "The majority element is the element that appears more than ⌊n / 2⌋".
@funnymoment9164 Жыл бұрын
Thanks!
@ShayanFallah-fj4ci2 ай бұрын
🔥
@tarunbhatt5003 Жыл бұрын
great video
@subee12810 ай бұрын
Thanks
@yash_14h Жыл бұрын
Why there are only three types of numbers? In array
@nikoo28 Жыл бұрын
you can have as many types.
@dineshkinibailoor34010 ай бұрын
the voting method returns 1 for me for array {1, 2, 2, 2, 3, 3, 1 } so is that logic correct? I think after your logic, we need to check again in the array if the count of the majority element is greater than (n/2) to be considered as the majority. In my case, the majority is returned as 1 but 1 is repeated 2 times which is not greater than the expected majority which is (>3). here we can suspect 2 could be the majority but it's not because it is not repeated more than 3 times.
@nikoo2810 ай бұрын
Majority element means the element which occurs more than n/2 times. Your test case is invalid, as it does not have a majority element. What you are talking about is the element occurring maximum number of times.
@mdsalik9374 Жыл бұрын
What if there is no majority element? How to handle that?
@nikoo2811 ай бұрын
then it will be an entirely different problem. What are you looking to find?
@abhishekchoudhary80236 ай бұрын
Can we do using 2 pointer
@nikoo286 ай бұрын
Give me a pseudo code for your approach
@enriquegrageda9 ай бұрын
Thanks man, good explaining, if i land a job, ill send you some money 😁
@nikoo289 ай бұрын
haha..thanks a bunch
@mdsalik9374 Жыл бұрын
Can we get n/3 solution as well?
@nikoo2811 ай бұрын
do you have a link to the problem?
@foodandjournieswithme87887 ай бұрын
It gives error when nums=[6,5,5]
@nikoo287 ай бұрын
What error are you getting? I tried the case again and it gives 5 as the output
@foodandjournieswithme87887 ай бұрын
@@nikoo28 sir i got output as 6 in the same code
@nikoo287 ай бұрын
@@foodandjournieswithme8788 check your test case and code again. Here is the verified output: github.com/nikoo28/java-solutions/blob/master/src/test/java/leetcode/easy/MajorityElementTest.java
@MeghnaMukesh-hd5zk5 ай бұрын
The mistake in the code is that the loop starts with i = 0, which causes the initial element to be counted twice. Specifically, when the loop starts, nums[0] is already assigned to the majority and the vote is set to 1. The loop then starts from i = 0, incrementing votes for the same element. The correct approach is to start the loop from i = 1. for (int i = 1; i < nums.length; i++)
@abhiguptamusic Жыл бұрын
Wrong Code (Wrong understanding of mine)
@nikoo28 Жыл бұрын
What part do you think is wrong?
@abhiguptamusic Жыл бұрын
@@nikoo28 first condition vote==0
@nikoo28 Жыл бұрын
@@abhiguptamusic That condition is absolutely correct, whenever votes become =0 you need to update your majority candidate, and then increase the vote count. What error do you see in the condition? Did you try running the code?
@abhiguptamusic Жыл бұрын
@@nikoo28 the code is not working with another test cases
@abhiguptamusic Жыл бұрын
@@nikoo28 please try with these test case [1,1,2,3,4]