We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defwaiter(number,q):# Write your code hereprim=[]forjinrange(2,5*10**4):n=2whilej%n:n+=1ifn==j:prim.append(j)iflen(prim)==len(number):breakans=[]foriinrange(q):b=[]forjinrange(len(number)-1,-1,-1):ifnumber[j]%prim[i]==0:b.append(number[j])number.pop(j)number=number[::-1]ans+=b[::-1]returnans+number[::-1]
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Waiter
You are viewing a single comment's thread. Return to all comments →