Whats wrong with my code to HARRY AND MAGICAL NUMBER?!
It even passed the sample case and some manual inputs which I tested it with so why am I getting WA.
Check my code ©:
int array, minimum, size, c,s;
for ( c = 0 ; c < size ; c++ )
minimum = array;
for ( c = 1 ; c < size ; c++ )
if ( array[c] < minimum )
minimum = array[c];
Your code fails on the test case
in the above given test value of K (as stated in question) is 3.
in your code u are only checking for the if the minimum number is K or not. Try changing your code dude…
Try this input:
1 12 18
You could try my solution…
I didn’t try it whether it is correct or not, because i didn’t find link to this question in practice problems.
I used Binary Search to solve this problem.and here is my solution.
Please try to submit it and tell me also whether it is right or wrong.
My solution is correct. I submitted it and got AC.