Showing:
Handle Score
@Ibrahim Nash 6420
@mb1973 5642
@Quandray 5233
@akhayrutdinov 5111
@saiujwal13083 4610
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3413
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.

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