+ 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

31st Jan 2019, 3:05 PM
Keyi Huang
Keyi Huang - avatar
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..
31st Jan 2019, 4:05 PM
Keyi Huang
Keyi Huang - avatar