We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Larry's Array
You are viewing a single comment's thread. Return to all 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