phumipatc / Algorithm

7 stars 13 forks source link

K-th Inversion based on number's position #13

Closed phumipatc closed 2 years ago

phumipatc commented 2 years ago

Find the K-th Inversion from the array of numbers

Order of inversions' based on their position in the original array

e.g. array [3, 2, 1] The order of inversions would be (3, 2), (3, 1), (2, 1)

Remark: Inversion is a pair of numbers that satisfy these conditions

  1. a[i] > a[j]
  2. i < j