Better inversion count algo