Тёмный

Majority Element 2 and 1 || Intuition + Example + Code || Find elements occuring more than n/3 times 

Code with Alisha
Подписаться 29 тыс.
Просмотров 12 тыс.
50% 1

Опубликовано:

 

27 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 43   
@siddhantganesh
@siddhantganesh 2 года назад
The game example just flipped my mind. And it was like...now I can never forget Moore's algo. The example you used was just amazing. Thanks Alisha
@shanayagupta4002
@shanayagupta4002 Год назад
i 100% agree with u
@nishantpratyush4191
@nishantpratyush4191 2 года назад
What a mind blowing explanation di🤯.... Was struggling with this question from the last two days.... I still can't believe that I understood🥺
@none2868
@none2868 Год назад
Was struggling with this problem. Your explanation was overwhelmingly helpful!
@gedelasivakrishna
@gedelasivakrishna 8 месяцев назад
I understand easily by your explination, thankyou !!
@siddhantganesh
@siddhantganesh 2 года назад
This is one of the best explanation for majority element !!!!
@gokulnaathbaskar9808
@gokulnaathbaskar9808 Год назад
Exactly!
@user-vj5fq6hf4k
@user-vj5fq6hf4k 2 года назад
best explanation on moore's so far...thank you so much
@probabilitycodingisfunis1
@probabilitycodingisfunis1 2 года назад
You're very welcome!
@gokulnaathbaskar9808
@gokulnaathbaskar9808 Год назад
Love your energy while teaching, the first part of the video is very clear, thank you so much
@kawaljeetsingh1657
@kawaljeetsingh1657 2 месяца назад
Thank you for the explanation, Simple, Best and No Story telling like others..... Straight to the point and saved good amount of time...... No doubts, Had to subscribe.....
@anonymousperson7586
@anonymousperson7586 4 месяца назад
one of the best explanation of this approach.
@durgeshkushwaha2534
@durgeshkushwaha2534 Год назад
Once again excellent explanation .thank you so much mam ❤❤ Honestly, whenever I want to find the solution to any question, I look for your video first :) And Thank you again for accepting the connection request on Linked In.
@niteshkoli007
@niteshkoli007 2 года назад
I will never forget the concept of this question 😂, game example was the best to remember it,🙌thank you so much.
@jeeva3118
@jeeva3118 Месяц назад
This Video help me to clarify my doubts..
@utkarshasingh1836
@utkarshasingh1836 Год назад
Probably the best explanation available.
@artyCrafty4564
@artyCrafty4564 Год назад
just WOW...i am speechless...cann't describe
@Shubham-yc6nz
@Shubham-yc6nz Год назад
Thanks for the game example. You are awesome teacher as always.
@KS0607
@KS0607 2 года назад
I think for N/3 question the coding is wrong. both candidate 1 & candidate 2 will be same by that code u r simply applying same conditions for two variables....how can outcome will be diff?
@pratikkumarjha5995
@pratikkumarjha5995 2 года назад
Didi can we use frequency array for this question...... Amazing explanation di...
@jkengineeringworkvideos7282
@jkengineeringworkvideos7282 2 года назад
nah that wont be constant space complexity
@lakshay6043
@lakshay6043 2 года назад
great explanation
@tarunbehera934
@tarunbehera934 Год назад
2nd for loop is for 0 winners, right?
@chandrakiran764
@chandrakiran764 Месяц назад
thank you for intution
@jatinlanje5741
@jatinlanje5741 2 года назад
this life and shoot example was really
@shivanshgupta1509
@shivanshgupta1509 2 года назад
ThanYou so much mam !!!!!
@MONUKUMAR-li8qg
@MONUKUMAR-li8qg 2 года назад
Great Explanation.
@sauravjha552
@sauravjha552 3 года назад
Nice Explaination
@mapradnardev
@mapradnardev 2 года назад
For N/2 majority element this return wrong answer for A={3,4,3,4,11} it returns 1 but it is not majority elemnt
@siddhantganesh
@siddhantganesh 2 года назад
Read the question carefully on leetcode. "The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array." The majority element always exist !
@mapradnardev
@mapradnardev 2 года назад
@@siddhantganesh i think we need to count the candidate element again to check for validity
@naveengoyal5243
@naveengoyal5243 2 года назад
@pradhan - For n/2 case, The question says "You may assume that the majority element always exists in the array", the example case (A={3,4,3,4,1,1}) you have taken for this question itself is wrong. The question says that you just have to find the majority element in the array and it will always exist in the array. While on the other hand, for n/3 case, it is never mentioned that "you can assume at least one n/3 element will exist", that's why we are counting and to know if 0 or 1 or 2 elements exists having more than n/3 count.
@vishwassahu
@vishwassahu 2 года назад
this soln won't work for [1,1,1]
@GhostRider....
@GhostRider.... 2 года назад
Which case you are asking for n/3 or n/2?
@Shubham-yc6nz
@Shubham-yc6nz Год назад
While counting add the second if in else block E.g If () cnt1++ Else if() cnt2++
@bhai-bm4kj
@bhai-bm4kj Год назад
love you didi
@ketansharma6955
@ketansharma6955 Год назад
wow!
@lavanyakataria101
@lavanyakataria101 2 года назад
Do share the code
@lavanyakataria101
@lavanyakataria101 2 года назад
Di, can you make a video on how to build logic, solution seems easy by watching your videos, but getting it done by myself is tough. How to build logic like you?
@GhostRider....
@GhostRider.... 2 года назад
@@lavanyakataria101 just do questions, after doing around 200 - 300 questions your logic will start building, and also revise these questions
@Idukhan-jj9kc
@Idukhan-jj9kc 3 года назад
👍👍👍👍💯
@inspired_enough_to_grow_up
@inspired_enough_to_grow_up 3 года назад
OS ki sheet dedo didi
@drop009
@drop009 2 года назад
you don't think you should provide links of your code . 🤔 rest the explanation was so good !
Далее
MAGIC TIME ​⁠@Whoispelagheya
00:28
Просмотров 3,7 млн
Count Inversions in Array
11:48
Просмотров 11 тыс.
Gas Station or Circular Tour problem
21:38
Просмотров 13 тыс.
Leetcode 62. Unique Paths || Code + Explanation
12:06
Majority Element - Leetcode 169 - Python
14:39
Просмотров 107 тыс.
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22