Switching directions in iterating 2D arrays
I do prefer the solution with the boolean. Also, a third possible variant would be to fill every other from left to right and remaining rows from right to left

In any case, they way you are supposed to handle arrays where size is not A*B might help you to pick the best solution for you.