Optimal inversion counting on int arrays

前端 未结 3 761
难免孤独
难免孤独 2021-02-08 23:30

Today I was looking the latest exam of the local informatics olympiad and I found a interesting problem. Briefly, it asks to, given an integer array, count how many inversions i

3条回答
  •  失恋的感觉
    2021-02-09 00:30

    O(n log n) is the best as far as I know.

    A detailed explanation was given here:

    http://www.geeksforgeeks.org/counting-inversions/

提交回复
热议问题