You are viewing a single comment's thread. Return to all comments →
Because your solution is O(n) for every query and n is too large and/or too many queries.
I did mine using sorted sets and then I counted how many elements had a subset with the right bounderies (O(log n) to find the bounderies).
Using tries would be even better as it would be O(log k) where k is the length of the string
Seems like cookies are disabled on this browser, please enable them to open this website
Tries: Contacts
You are viewing a single comment's thread. Return to all comments →
Because your solution is O(n) for every query and n is too large and/or too many queries.
I did mine using sorted sets and then I counted how many elements had a subset with the right bounderies (O(log n) to find the bounderies).
Using tries would be even better as it would be O(log k) where k is the length of the string