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.
Great googly moogly. Here's a list of the things I had to do to avoid the timeout on cases 11-13.
Change the boilerplate code to use no non-primitive storage.
Change the function to the following signature: static int[] freqQuery(int[][] queries, int numChecks, int numAdds). Passing in the number of checks ('3'-queries) allows the function to return an int[].
Passing in the number of additions ('1'-queries) allows some space optimization by allowing the function to use a shorter int array to track frequencies, rather than a map.
Reduce ALL non-primitive storage in the function to a single map.
In the final print in main(), use a StringBuilder and a single print statement, rather than printing in the loop.
Hope that helps people who are as stuck as I was!
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Frequency Queries
You are viewing a single comment's thread. Return to all comments →
Great googly moogly. Here's a list of the things I had to do to avoid the timeout on cases 11-13.
Hope that helps people who are as stuck as I was!