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.
BigInteger comparisons require converting to integers from strings then comparing as integers which is slow and inefficient.
You can easily override a String[] comparator to be whatever you like and still get the benefits of Java doing a double pivot quicksort without you having to code it
If you use a StringBuilder to build your ouput and then only make a single System.out call it will be much faster because I/O is slow
Java Solution
Here is my solution in Java that passes all cases in O(n log(n)) time with O(n) space.
For more solutions like this check out the HackerRank Github repo here
Big Sorting
You are viewing a single comment's thread. Return to all comments →
Here are the key things to think about:
Java Solution Here is my solution in Java that passes all cases in O(n log(n)) time with O(n) space.
For more solutions like this check out the HackerRank Github repo here