WA in some test cases

Hi Can you please highlight mistake in implementation.

Please Give some test case where it is failing


Will fail for
3
1 1 2
Here majority element is 1 but your code will give no majority element.
also its floor value so majority element should be >=n/2
Also handle these test cases
1
1 ans->1
5
1 1 1 1 1 ans->1
2
1 2 ans->1 2

Handle all the above test cases .

Bhaiya,Can you please check the code again,Its working for the test cases mentioned.

Also If I take >=n/3 Then For test Case n=3 , arr[]={1,1,2} 2 will become majority element,which is not correct…

Hey ,In your code remove line 30-33 , its changing the output order in case of multiple majority elements
Also do not forget to mark this as resolved:)

Actually Wrong order is mentioned in Sample Output (min,max).But Thanks a lot !!

1 Like