thank you so much sir....ur explanation needs a honor....by watching your fantastical explanation for first 5mins....i coded the solution...once again thanks sir
Thank you sir....for such a beautifully explained optimal solution! Your content is really commendable....! Thanks a ton for the whole superb playlist , it's really helpful to me....!!
Great way of explanation, I am beginner and for me this explanation with slow place and multiple time. Make me understand in more better way than other videos where they just take pen and paper and just walk through the program
This array doesn't have majority element because n=7 then majority element is greater than the 7/2 = 3 i.e element should appear more than the 3 times 6-2 times 3-3 times 4-1 time 2-1 time there is no element which appearing more than n/2 (>3)
@@SYD_Technologies this is the reason that every one tells us to read questions, as in the question it self mentioned that the majority element will be in the array
thank you so much sir....ur explanation needs a honor....by watching your fantastical explanation for first 5mins....i coded the solution...once again thanks sir
Thank you sir....for such a beautifully explained optimal solution! Your content is really commendable....! Thanks a ton for the whole superb playlist , it's really helpful to me....!!
Great way of explanation, I am beginner and for me this explanation with slow place and multiple time. Make me understand in more better way than other videos where they just take pen and paper and just walk through the program
Great Explanation !! Thank You !! From this Explanation very helpful for me!!
Great Explanation !! Thank you!
what if the array is 6,6,3,3,4,3,2
This code doesn’t work for all the test cases.
This array doesn't have majority element because n=7 then majority element is greater than the 7/2 = 3 i.e element should appear more than the 3 times
6-2 times
3-3 times
4-1 time
2-1 time
there is no element which appearing more than n/2 (>3)
@@SYD_Technologies this is the reason that every one tells us to read questions, as in the question it self mentioned that the majority element will be in the array
It fails on multiple test cases😮😢
Can this be a solution when there is majority element.
1.sort an array (0(logn))
2.int i=1
While(in/2)
Break;
else
Count=0;
i++;
}
Return i-1;
If there is not maj element then value of count will be 1 just use if at the end of loop if count ==1 return -1;
if your sorting a array the efficient time complexity is O(nlogn)
this is the code if no majority element:
int maj=arr[0];
int coun=1;
for(int i=0;i