You are viewing a single comment's thread. Return to all comments →
I did it almost like you. I just didnt use StringBuilder, only System.out.print(char) everytime you deal with one of them into the deepest for loop, and System.out.println() everytime that loop ends, so you can keep some memory space and also the last for loop for printing the grid is not necessary.
I dont know if there's a better solution in Java, but I bet this one could be =)