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.
This algorithm is actually O(Nlog(N)) because of the sorting, we can make it O(N) by using a counting sort since we know what the maximum element of our array will be. you will have to replace the line
Flatland Space Stations
You are viewing a single comment's thread. Return to all comments →
Here is my easy c++ solution, you can watch the explanation here : https://youtu.be/k2pd5_9mseI
This algorithm is actually O(Nlog(N)) because of the sorting, we can make it O(N) by using a counting sort since we know what the maximum element of our array will be. you will have to replace the line
with this
And add this sort function in your editor