Skip to content

Instantly share code, notes, and snippets.

@ZakriaJanjua
Last active March 30, 2024 23:27
Show Gist options
  • Save ZakriaJanjua/a39270f47902cdfaa0ecfd4545a0f125 to your computer and use it in GitHub Desktop.
Save ZakriaJanjua/a39270f47902cdfaa0ecfd4545a0f125 to your computer and use it in GitHub Desktop.
Counting Sort algorithm in Python
# defines the range of the numbers that will be input in the array
RANGE = 100
def countingSort(arr):
# Write your code here
count = [0] * RANGE
result = []
for i in arr:
count[i] += 1
for idx, ele in enumerate(count):
if (idx * ele > 0):
result.extend([idx for i in range(ele)])
return result
@ZakriaJanjua
Copy link
Author

@thechaak can you provide me the input

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment