Little help with the code

getting an error of time limit exceeded.


You need to solve using efficient method brute force will not work.
Share your code for further help. :blush:

@faizahmed2696 Hi, in addition to using a sieve, you have to precompute the primes as well. by precompute i mean computing the list of primes and storing them upto the given upper limit of constraints.

So first study about sieve if you don’t know, then refer my code below.
Precomputing is important!
Also if ya doubt is cleared mark it resolved and rate full!
Happy coding!

after applying sieve still getting TLE

@faizahmed2696 have you referred my code above?