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.
defpickingNumbers(a):# Write your code herea.sort()begin=0end=1max_length=0current_length=1whileTrue:ifa[end]-a[begin]<=1:end+=1current_length+=1else:begin+=1end=begin+1current_length=1ifcurrent_length>max_length:max_length=current_lengthif(begin>=len(a))or(end>=len(a)):breakreturnmax_length
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Picking Numbers
You are viewing a single comment's thread. Return to all comments →
python 3