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.
In my case, the timeout was occurring because I was using Scanner.nextLine() in order to read each input line and then parsing the String to determine the query type and value. It turns out that this resulted in at least .5 seconds added just processing input. When I changed to Scanner.nextInt(), all tests passed within 1.5 seconds.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Element
You are viewing a single comment's thread. Return to all comments →
In my case, the timeout was occurring because I was using Scanner.nextLine() in order to read each input line and then parsing the String to determine the query type and value. It turns out that this resulted in at least .5 seconds added just processing input. When I changed to Scanner.nextInt(), all tests passed within 1.5 seconds.