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.
publicstaticList<Integer>quickSort(List<Integer>arr){// Write your code hereintn=arr.size();List<Integer>left=newArrayList<>();List<Integer>right=newArrayList<>();List<Integer>equal=newArrayList<>();intp=arr.get(0);for(inti=0;i<n;i++){if(p>arr.get(i)){left.add(arr.get(i));}elseif(p<arr.get(i)){right.add(arr.get(i));}else{equal.add(arr.get(i));}}List<Integer>result=newArrayList<>();result.addAll(left);result.addAll(equal);result.addAll(right);returnresult;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
Quicksort 1 - Partition
You are viewing a single comment's thread. Return to all comments →
java Solution