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.
We want to sort in descending order while preserving the contents of each String. A comparator can achieve this for us. We convert to BigDecimal inside our comparator so that the change is not permanent and our String's form for each number is preserved.
Java BigDecimal
You are viewing a single comment's thread. Return to all comments →
Java solution - passes 100% of test cases
From my HackerRank solutions.
We want to sort in descending order while preserving the contents of each String. A comparator can achieve this for us. We convert to BigDecimal inside our comparator so that the change is not permanent and our String's form for each number is preserved.
Let me know if you have any questions.