• + 0 comments

    this really just asks if you have an even permutation. you can calculate the sign in linear time by multiplying up the signs of each cycle within - the code is relatively straightforward. counting inversions may work too, although this is quadratic