Bitset solution for validating permutations.