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.
TreeMaps are awesome, but I don't think this is an O(n) solution. Each time you put an element into a TreeMap it takes log(n) time. You are putting n elements into the TreeMap, so it takes O(n log n) total time.
Cut the sticks
You are viewing a single comment's thread. Return to all comments →
TreeMaps are awesome, but I don't think this is an O(n) solution. Each time you put an element into a TreeMap it takes log(n) time. You are putting n elements into the TreeMap, so it takes O(n log n) total time.
HackerRank solutions.