Skip to content
Advertisement

Sort String of Characters Using Hashed Array and Java 8 Streams

I stumble upon this cool sorting algorithm with O(n) time complexity on GeeksforGeeks – Sort string of characters and I was trying to refactor the code to use Java Streams on the nested for loops instead and collect the result in a string variable but I can’t seem to wrap my head around it.

Here’s the original code:

JavaScript

Advertisement

Answer

Try this.

JavaScript

output:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement