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.
You can speed this up, doing the contains on a list is O(n) and contains in a set is O(1). If you keep a hash set of things you have seen and what index they map to then you can turn this O(N^2) solution into O(n)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Ice Cream Parlor
You are viewing a single comment's thread. Return to all comments →
You can speed this up, doing the contains on a list is O(n) and contains in a set is O(1). If you keep a hash set of things you have seen and what index they map to then you can turn this O(N^2) solution into O(n)