here we are computing prime no upto 10^6
so this will take time to approximately 10^6
this isnt it making each query expensive
Related to time complexity
@deepakjumani09
hello Deepak,
No because we are computing prime numbers only once and after that for each query we are answering in O(1) time so total time complexity will be o( Q + nlog(logn) ) .
which is efficient
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.