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

preview_player
Показать описание
Majority element 2 :
Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.

Follow-up: Could you solve the problem in linear time and in O(1) space?

Majority element 1 )
Given an array nums of size n, return the majority element.

The majority element is the element that appears more than ⌊n / 2⌋ times.
Рекомендации по теме
Комментарии
Автор

one of the best explanation of this approach.

anonymousperson
Автор

What a mind blowing explanation di🤯.... Was struggling with this question from the last two days.... I still can't believe that I understood🥺

nishantpratyush
Автор

Was struggling with this problem. Your explanation was overwhelmingly helpful!

none
Автор

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

siddhantganesh
Автор

I understand easily by your explination, thankyou !!

gedelashilpa
Автор

best explanation on moore's so far...thank you so much

vjfqhfk
Автор

Love your energy while teaching, the first part of the video is very clear, thank you so much<3

gokulnaathbaskar
Автор

just WOW...i am speechless...cann't describe

artyCrafty
Автор

This is one of the best explanation for majority element !!!!

siddhantganesh
Автор

Probably the best explanation available.

utkarshasingh
Автор

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.

durgeshkushwaha
Автор

I will never forget the concept of this question 😂, game example was the best to remember it, 🙌thank you so much.

niteshkoli
Автор

Thanks for the game example. You are awesome teacher as always. <3

Shubham-ycnz
Автор

this life and shoot example was really

jatinlanje
Автор

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?

KS
Автор

Didi can we use frequency array for this
Amazing explanation di...

pratikkumarjha
Автор

this soln won't work for [1, 1, 1]

vishwassahu
Автор

2nd for loop is for 0 winners, right?

tarunbehera
Автор

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

mapradnardev
Автор

you don't think you should provide links of your code . 🤔
rest the explanation was so good !

drop