You are viewing a single comment's thread. Return to all comments →
This fixed timeout on 9-12 for me, on Java 8. The other suggestions to change the boilerplate by passing in did not, but this worked.
Can someone explain why though? Is there a memory constraint problem with passing in the 2D array instead of the bufferedReader, consequentially slowing the program down? Not too sure what's the difference.
The thing with the 2D array is that you read all the inputs first to build the array and then you process them again one-by-one. This solution will process the current input upon reading it which is relatively faster since you don't have to go through the array again.