Triple Inversion?

Revision en1, by dhruvmullick, 2015-06-13 20:34:33

I was doing TRIPINV. The problem requires us to find triplets with ai > aj > ak for i < j < k.

I was thinking of using 2 BITs for the same, and use a (Sum) C (2), and of sum of (SameElements) C (2). But I can't maintain the order of elements this way. For instance, in A[1..6] = 3 2 1 3 2 1 My program would identify A[2],A[5],A[6] as a triplet too.

Can anyone help me out?

PS: C denotes Combination


  Rev. Lang. By When Δ Comment
en1 English dhruvmullick 2015-06-13 20:34:33 492 Initial revision (published)