Problem Solving :: Largest Prime from Toph

In this problem, task is to find out the largest prime number in a given range.
Statement says Q (1 ≤ Q ≤ 10^5), the number of queries that will be given. The next Q lines will contain two integers li (1 ≤ li) and ri (ri ≤ 10000).
So for solving this, I used a sieve algorithm for storing all the prime numbers is an array from 1 to 10000. Then I apply binary search for each query.

Comments

Popular posts from this blog

Java notes Date:26/11/2019

Problem Solving:: Be Like Hasib from Toph