You are viewing a single comment's thread. Return to all comments →
This solution is actually O(n) space: you use actual array of (n+1) elements. And time is O(n+m)
This task can be solved with O(m log m) time and O(m) space. For this task, it's better.
Seems like cookies are disabled on this browser, please enable them to open this website
Array Manipulation
You are viewing a single comment's thread. Return to all comments →
This solution is actually O(n) space: you use actual array of (n+1) elements. And time is O(n+m)
This task can be solved with O(m log m) time and O(m) space. For this task, it's better.