The Full Counting Sort

  • + 0 comments

    Python best solution

    If you’re looking for solutions to the 3-month preparation kit in either Python or Rust, you can find them below: my solutions

    def full_counting_sort(arr):
        #Time complexity: O(n)
        #Space complexity (ignoring input): O(1)
        sorted_array = [""]*101
        for index in range(0, len(arr)):
            sorted_index = int(arr[index][0])
            if index < len(arr)/2:
                sorted_array[sorted_index] += " -"
            else:
                sorted_array[sorted_index] += " "
                for letter in arr[index][1]:
                    sorted_array[sorted_index] += letter
    
        result_string = ""
        for string in sorted_array:
            result_string += string
    
        print(result_string[1:])