https://online.codingblocks.com/player/15114/content/7561/4712?tab=submissions(Problem code)
third case is giving time limit error
https://online.codingblocks.com/player/15114/content/7561/4712?tab=submissions(Problem code)
third case is giving time limit error
Hello @Chetan_Khandelwal,
You need to use optimised prime sieve approach to solve this question in order to avoid getting time limit exceeded.
Before taking any inputs, declare a boolean array and mark all the primes as 1 using sieve of eratosthenes.
Then for each testcase check for primes by checking if the number is marked 0 or 1 in the array.
For Prime sieve, refer to the tutorial videos on the online.codingblocks.com portal.
Do ask if any you encounter any problems.