You are viewing a single comment's thread. Return to all comments →
import math import os import random import re import sys
def countingSort(arr, n): count = [0] * 100 # Fixed-size array of 100 elements
for num in arr: count[num] += 1 # Count occurrences efficiently return count
if name == 'main': fptr = open(os.environ['OUTPUT_PATH'], 'w')
n = int(input().strip()) arr = list(map(int, input().rstrip().split())) result = countingSort(arr,n) fptr.write(' '.join(map(str, result))) fptr.write('\n') fptr.close()
Seems like cookies are disabled on this browser, please enable them to open this website
Counting Sort 1
You are viewing a single comment's thread. Return to all comments →
!/bin/python3
import math import os import random import re import sys
def countingSort(arr, n): count = [0] * 100 # Fixed-size array of 100 elements
if name == 'main': fptr = open(os.environ['OUTPUT_PATH'], 'w')