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.
My Java solution with o(n) time complexity and o(1) space complexity:
publicstaticList<Integer>countingSort(List<Integer>arr){// init freq arrayint[]freqArr=newint[100];//update freq for each valfor(intelement:arr)freqArr[element]++;//return int array converted into Integer listreturnArrays.stream(freqArr).boxed().collect(Collectors.toList());}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Counting Sort 1
You are viewing a single comment's thread. Return to all comments →
My Java solution with o(n) time complexity and o(1) space complexity: