Leaderboard
Showing:
Handle Score
@Ibrahim Nash 6420
@blackshadows 6380
@mb1973 5642
@Quandray 5233
@akhayrutdinov 5111
@saiujwal13083 4610
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3413
Complete Leaderboard
Find the highest occurring digit in prime numbers in a range
Easy Accuracy: 26.08% Submissions: 280 Points: 2

Given a range L to R, the task is to find the highest occurring digit in prime numbers which lie between L and R (both inclusive). If multiple digits have same highest frequency return the largest of them. If no prime number occurs between L and R, return -1.
 

Example 1:

Input: L = 2, R = 10
Output: 7
Explanation: Between 2 and 10 every digit
has same frquency and 7 is largest among
them.

Example 2:

Input: L = 2, R = 20
Output: 1
Explanation: Prime number between 2 and 20 are 
2, 3, 5, 7, 11, 13, 17, 19. 1 occur 
maximum i.e 5 times among 0 to 9.


Your Task:  
You dont need to read input or print anything. Complete the function maxDigit() which takes L and R as input parameter and returns the highest occuring digit. If multiple digits have same highest frequency return the largest of them. If no prime number occurs between L and R, return -1.

Expected Time Complexity: O(nlog(n)sqrt(n))
Expected Auxiliary Space: O(k)

Constraints:
1 <= L<= R <= 1000

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Find the highest occurring digit in prime numbers in a range

Output Window