+ 3

# How to make my code more efficient?

Qn is here(my code exceeds the time limit of 5s) Given the natural numberÂ 1â€nâ€10^5and the array of integersÂ A[1âŠn], not exceedingÂ 10^9Â by absolute value. OutputÂ 1, if the arrayÂ AÂ contains a number occurring strictly more thanÂ n/2Â times, and outputÂ 0Â otherwise. https://code.sololearn.com/cZgAVjY4mj5h/?ref=app

1 Answer

0

I hv updated the correct version of the qn. Here is a sample of input and output:
Input:
5
2 5 3 2 2
Output:
1
obviously this one my code still can do within 5 seconds, but the website wont tell me what input is given by the test I failed(time limit exceed)...but i do know that there are some really complicated imput like N=10^5 so the only way now is that if you guys have any thoughts of modification just put it here so that i can check with the website if it can pass the tests..