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.
Flatland Space Stations
Flatland Space Stations
Sort by
recency
|
943 Discussions
|
Please Login in order to post a comment
Here is problem solution in Python, Java, C++, C and Javascript - https://programmingoneonone.com/hackerrank-flatland-space-stations-problem-solution.html
There is an error in the C stub for this. I am getting "Runtime error" in Test case 6 and 13 even if I immediately return 0 from the funciton.
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