Help needed to know why 3 test cases failed in my submission

Hi, in my submission, 3 test cases passed and 3 failed. I am not sure what is wrong with my code. It looks OK and similar to the solution provided under the solution tab for this question. Also, test case 2 has a very large input array, so how to run this test case individually to see what failed in this test case? Should we do a read file operation and then form a vector?

Hi, I just tried your solution also from editorial, it also fails first 3 test cases.

hi @bksingh05_b7112183fadff667, try this

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Hi, Thank you for your reply. Your code worked, with minor modification. I found out the reason of failure in my code. The reason is that if I allocate a vector statically, instead of reading it from console through cin, then the code fails. If I put in the code to read the input vector from console, then my previous code (with unordered_map) also passes. To be precise, here is the code change that I did in my previous code to make that code work.

/*
vector<int> a{1, 2, 3, 1};
int n = (int) a.size();
*/

vector<int> a;
int n;

int num;

cin>>n;

for(int i=0; i<n; i++)
{
    cin >> num;
    a.push_back(num);
}