menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Data Science News

>

2523. Clos...
source image

Dev

1M

read

104

img
dot

Image Credit: Dev

2523. Closest Prime Numbers in Range

  • Given two positive integers left and right, find the two closest prime numbers within the given range.
  • If multiple pairs have the same minimum difference, return the pair with the smallest starting prime.
  • If there are fewer than two primes in the range, return [-1, -1].
  • The algorithm uses the Sieve of Eratosthenes to efficiently generate prime numbers.

Read Full Article

like

6 Likes

For uninterrupted reading, download the app