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.
{
List<int> left = new List<int>();
List<int> right = new List<int>();
List<int> equal = new List<int>();
List<int> partition = new List<int>();
for (int i = 0; i < arr.Count; i++)
{
if (arr[i] < arr[0])
{
left.Add(arr[i]);
}
if (arr[i] > arr[0])
{
right.Add(arr[i]);
}
if (arr[i] == arr[0])
{
equal.Add(arr[i]);
}
}
partition = left.Concat(equal).Concat(right).ToList();
return partition;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Quicksort 1 - Partition
You are viewing a single comment's thread. Return to all comments →
c#
public static List quickSort(List arr)