Runtime Error!

My Solution-

Sorry, but i won’t be of much help in C++

1 Like

The error is because of array bounds.
The maximum size of vector primes is the total number of primes less than
5000001. But here you are required to find the 5000000th prime which is surely not possible.
Look at my code :

1 Like

Re-read the constraints (and the problem)