Show how the algorithm could be changed for the two-dimensional case, and generalize your algorithm to work with higher numbers of dimensions.
Show how the computation of the skipArray can be significantly improved. (It can be done in time O(M).) This is not an easy problem.