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.
Here is my python solution, the question is kind of confusing though.
defpickingNumbers(a):# Write your code herea.sort()result=[[a[0]]]last_index=1foriteminresult:forindexinrange(last_index,len(a)):last_index+=1if(abs(min(item)-a[index])<=1):item.append(a[index])else:result.append([a[index]])breakreturnlen(sorted(result,key=lambdax:len(x))[-1])
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 →
Here is my python solution, the question is kind of confusing though.