You are viewing a single comment's thread. Return to all comments →
I don't think I could ever have come up with something like that!
Is this considered a greedy solution?
One thing I did change was to make the array size N+2 and skipped the bounds check.
Yes, N+2 is required, otherwise gives an out of bounds error!