• Jankatarch@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    2 days ago

    This algorithm takes K seconds where K is the value of the greatest element.

    This means if you just multiply everything by -1 it will take negative time to sort.

    Then you can simply unmultiply and read from end to beginning from now on.

    This is faster than having it presorted.