Number of nth permutations with k inversion pairs

Revision en1, by SPyofgame, 2020-07-22 16:31:06

Simplest way:

Approach
Brute-force <TLE> - O(n! * n ^ 2) time - O(n) space

Improving the algorithm

Approach
BIT, Binary-search, Dynamic-programming <TLE> - O((n! * n + n) log n) time - O(n) space

Using formula to improve furthur more

Approach
Recursive Dynamic Programming Approach <AC> - O(n * k) time - O(n * k) space
Iterative Dynamic Programming Approach <AC> - O(n * k) time - O(k) space

I solved this problem but I wonder if there is a better way (faster than $$$O(n \times k)$$$)

So my question is "Is there a faster approach for this problem ?"

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English SPyofgame 2020-07-22 16:31:06 7395 Initial revision (published)