Hello. I'm new to C++ and I have a task for my homework to check whether odd or even number was added to an array. All the numbers in it are the same (even or odd) except one which I have to find. The size of an array is big (10^12) so the code runs into time limit exceeded error while checking all the numbers. I have this code below that I wrote by myself, but the only suggestion I received for fixing this issue was avoid storing all the user input values. I have no idea how to do that, so maybe anyone could help me with this?
> The size of an array is big (10^12)
> longlong a[10000000];
I want to store the sea and you give me a bucket.
> All the numbers in it are the same (even or odd) except one which I have to find
¿what do you need to find? ¿the actual value or only if it is even or odd?
Hmm. what school has TLE on homework problems?! Codechef U?
% is probably more cpu clocks than == or &1
unclear, are all the values the *same* except 1, or are they all the same even/odd except 1?
regardless all you need is
get first value. get some info from it based off actual problem (odd/even or just its value, depending?)
do
get input
while(input vs firstinput condition not matched)
and its done. you have found it. no array/storage .