Frequency Queries

  • + 0 comments

    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!