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.
Also, if someone still struggles with tests 12 and 13 due to timeout, use: List<Integer> result = new ArrayList<>(queries.size()); instead of List<Integer> result = new LinkedList<>();.
Of course we potentially allocate unnecessary memory in ArrayList (if queries contains other operations than operation 3), but this tric is to pass those tests. I.e. LinkedList will be better only with small amount of operations 3.
Frequency Queries
You are viewing a single comment's thread. Return to all comments →
Also, if someone still struggles with tests 12 and 13 due to timeout, use:
List<Integer> result = new ArrayList<>(queries.size());
instead ofList<Integer> result = new LinkedList<>();
.Of course we potentially allocate unnecessary memory in ArrayList (if queries contains other operations than operation
3
), but this tric is to pass those tests. I.e. LinkedList will be better only with small amount of operations3
.