class Solution: def primeSubOperation(self, nums: List[int]) -> bool: #get prime nos from 1-1000 prime=set([2,3,5,7,11,13,17,19,23,29]) maxx=max(nums) n=len(nums) for i in range(30,maxx): for j in range(2,ceil(i**(0.5)+1)): if(i%j==0): break else: prime.add(i)
def findBiggestPrimeLessThanNum(num): nonlocal prime if(num10
❤❤❤❤
English Explanation in this Video: ua-cam.com/video/ZpXhDe2JNvc/v-deo.htmlsi=Cjb0qmGgb7pN-dQi
class Solution:
def primeSubOperation(self, nums: List[int]) -> bool:
#get prime nos from 1-1000
prime=set([2,3,5,7,11,13,17,19,23,29])
maxx=max(nums)
n=len(nums)
for i in range(30,maxx):
for j in range(2,ceil(i**(0.5)+1)):
if(i%j==0):
break
else:
prime.add(i)
def findBiggestPrimeLessThanNum(num):
nonlocal prime
if(num10
# 2*50
# 5*20
# 10*10
# [4,9,6,10]
# [1,2,3,5]
# 4-3
# 9-1=8
# 9-7=2
# 6-2=4
# 6-3=3
# 10-3=7
# 10-5=5