+ 2

Finding number of perfect inverted pairs

An inverted pair in a sequence of numbers a1, a2, a3.... is defined as a pair < ai , aj > such that i<j and ai > aj . Now we define a perfect inverted pair as a pair < ai , aj > such that i<j and ai > 2 ∗ aj . Given a finite sequence of numbers, you need to find the number of perfect inverted pairs. Input-5 2 3 4 1//array original output-4 input-5 6 7 5 1 2 3 output-9 Note:- this questiin has ti be done in nlog n complexity

11th Mar 2018, 7:57 AM
Nikhil Kohli
Nikhil Kohli - avatar
4 Antworten
+ 1
Is this work for school or university? No way I'm going to help you cheating.
11th Mar 2018, 8:26 AM
Timon Paßlick
+ 1
Ok, I apologize.
11th Mar 2018, 5:26 PM
Timon Paßlick
0
it is just a practice question that i have got from my friend.
11th Mar 2018, 5:23 PM
Nikhil Kohli
Nikhil Kohli - avatar
0
i have done this but in n^2 .
11th Mar 2018, 5:24 PM
Nikhil Kohli
Nikhil Kohli - avatar