Problem link:
https://online.codingblocks.com/app/player/115374/content/73624/5142/code-challenge
Code link:
Problem link:
https://online.codingblocks.com/app/player/115374/content/73624/5142/code-challenge
Code link:
Try this:
Can you please check my solution, and tell the error?
Your code is giving TLE because total number of primes upto 10^6 is of the order 10^5 and maximum number of elements in this question is 10^4 making the total complexity of 10^9. Hence, giving tle.