Nearest Prime. Hackerearth

getting TLE in one case plz help!!
Question link-https://www.hackerearth.com/practice/math/number-theory/basic-number-theory-2/practice-problems/algorithm/nearest-prime-a828361b/#:~:text=Joy%20is%20a%20hacker%20at,the%20smallest%20one%20of%20them.
My Code link-https://ide.codingblocks.com/s/336112

hello @Bhawna
image
here u are using push_back to many time may be thats why it is showing tle.
do one thing create a count variable ,and store total count of prime in it.
then declare ur vector of that size.
and use indexing in place of push back

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.