CountInversion better solution