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.
n=int(input().strip())bucket={}# read all integers as strings, store them by length in the bucketfor_inrange(n):number=input().strip()length=len(number)# create new bucket for lengthifnotlengthinbucket:bucket[length]=[]bucket[length].append(number)# read from the bucket in ascending orderforkeyinsorted(bucket):forvalueinsorted(bucket[key]):print(value)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Big Sorting
You are viewing a single comment's thread. Return to all comments →
python3 with bucketsort: