DEEPAK AND PRIMES TEST CASE 4 NOT PASSING

I have create a sieve and tried to store the prime numbers in an array. Now, I am getting wrong answer in the second last test case. Can someone help me with deciding the correct value of Msize so that I don’t get segmentation error? Because the value mentioned in editorial i.e 1000005 is giving me segmentation fault.


^^^^^^^^^^^^^^ MY CODE ^^^^^^^^^^^^^

hello @manisini.chakraborty as the test cases are larger and you have to store only 0 and 1 so the bitset array of size given in constraint will work.try that .
Happy Learning !!

1 Like

@tusharaggarwal272 please rephrase

@manisini.chakraborty what you haven’t understood?

“bitset array of size given in constraint will work” , do you mean to say instead of int array i should use bitset as datatype?

bitset is used for storing only 1 and 0 in the array and its size is less then the integer array .
bitset<1000000>b(0) you can prepare the array like this and then you can check on this

yes it worked. thanks a lot

@manisini.chakraborty if you feel that your doubt is cleared please mark this doubt as resolved .
in case you have doubt you can reopen the doubt again .
Happy Learning !!