Closest Prime Numbers In Range [left, Right]
Here's the summary of the blog post in 250 characters or less: "Find closest prime numbers within range [left, right]. Use Sieve of Eratosthenes to generate primes up to right value. Collect primes in range and find pair with min difference.
2523. Closest Prime Numbers in Range Difficulty: Medium Topics: Math, Number Theory Given two positive integers left and right, find the two integers num1 and num2 such that: left <= num1 < num2 <= right . Both num1 and num2 are prime numbers1. num2 - num1 is the minimum amongst all other pairs satisfying the above conditions. Return the positive integer array ans = [num1, num2]. If there are multiple pairs satisfying these conditions, return the one with the smallest num1 value. If no such numbers exist, return [-1, -1]. Example 1: Input: left = 10, right = 19 Output: [11,13] Explanation:...