1 test case is getting run time error.
Prateek and candies problem
Create your sieve array before taking any inputs.
I have also made some changes to your sieve function. Check and tell me if you get the logic.
But what is wrong in my sieve function. It worked pretty well with other problems.
Yes your code correct. Just call your sieve function before taking inputs for test cases so that the sieve array is not computed again and again for each value of n.
Tell me if you get all the test cases right.
I’m calling sieve before taking inputs.But one of them is still failing. But if i use the sieve function u wrote, its passing. Why is that? What is wrong is my code??
Your code is passing all the given test cases.
I have just written the “vector *primes = sieve();” statement outside the while function in int main().
Rest is fine.
oh yes, it is now. Thank you.