Majority Element | Leetcode 169 |Moore's voting algorithm | Top 150 interview question series
ฝัง
- เผยแพร่เมื่อ 15 พ.ค. 2023
- Top 150 interview question series
Majority Element
Leetcode problem number 169
JAVA interview programming playlist:
• Interview Programming ...
Git Repo:
github.com/Technosagelearning... - วิทยาศาสตร์และเทคโนโลยี
Sister the way you explaining blows my mind don't stop teaching you are so good !
I appreciate your way of explaining.....thank you❤🙏
But the algorithm is limited to work only if two different elements appears on the array, for more than 2 different elements it won't work. It's kind of restricted functionality.
Yes so then what's the solution?
If you know then please reply
Thank you so much mam, for such simple and accurate explaination.
A big shout out to you Mam. You made topics clear, simple and explanations were on point. A big thank you for all your efforts. If time permits, I humbly request you to please continue the 150 interview leetcode problems.
Hey..i will continue the series very soon..stay tuned
it is very useful...thank you
Awesome 👍👍👍👍 mam
[6,5,5] on that test case answer will be would could you tell me why ??
Hi
I'm really grateful for this highly self explanatory piece,
one point that I am in need of clarification: the input is supposed to be 'non-zero', , is that correct please ?
Hey these videos are really helping me .... can you please complete these 150 sheets playlist , turn out to best resource for me till now. please🙂🙂
will there will be only 2 types of elements in the array ... suppose [1,1,2,3,0,1] here it is 4 diffetnet element ...so what will be output for it.. and 2 or 3 will not try to decrese their point instead of against 1 ..
Hi Harshal, understand the question properly. Input array always have the majority element which means count a element should be more the n/2. In your example [1,1,2,3,0,1], I don't see any majority element. To 1 be the majority element, four 1s should be in the input array. Hope this helps you! Happy learning!
@@manirajsivasubbu i got it bro when i wnet to imolement it
@@manirajsivasubbu but ty
Sir muje VMware me job Leni hai to uske liye kya kya karna padega
please continue this series
Sure 😊
best
good
you dint verified the case that majority element should be more the n/2 ????
Mam please upload the Leetcode question no 238 Product of Array Except Self
This is only works for these two examples. If the the elements of the array getting longer it won't work.
The solution does not work for different arrays.
Please mam you continue solve LEETCODE questions
Hi..Will upload videos very soon..
@@TechnosageLearning One day your youtube channel will increase a lot of subscribers
Thank you🙏
Mam,given example me '3' ka count 1 ayya h lekin apne ko more than '1'(n/2) chaiye tha , apne ko pta h ki '3' total 2 times h lekin question m kese pta chla ki 3 more than 1(n/2) times h , kioki last m to count '1' hi bachha tha, mtlb usne compare kese kiya length se?
Mam why there are only three types of numbers.?? In array 😢
That is only an example..you can take any type of numbers
why u have stop the series you may complete it all plzzzzzzzzzz
Hi
Starting very soon..working on it..Please stay tuned
@@TechnosageLearning as soon as possible am waiting
it fails when arr is - 3,3,4
No its not failing ..in this case,majority element is 3 and output is also 3..you can try the code from git repo..You might be missing something
I'm a beginner. After what topics should i learn time and space complexity maam,
also i wrote this code and got the answer:
class Solution {
public int majorityElement(int[] nums) {
int n = nums.length;
for(int i=0;i