We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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 =)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Cavity Map
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 =)