Basic example
Input
lomuto_quicksort([3, 6, 1, 5, 2])
Output
[1, 2, 3, 5, 6]
The input list is sorted into ascending order using Lomuto quicksort and the sorted list is returned.
Full lesson preview
Implement quicksort using the Lomuto partition scheme to sort a list of integers in-place and return a new sorted list.
Problem statement
Task
Examples
Input
lomuto_quicksort([3, 6, 1, 5, 2])
Output
[1, 2, 3, 5, 6]
The input list is sorted into ascending order using Lomuto quicksort and the sorted list is returned.
Input format
Output format
Constraints
Samples
Input
[4, 2, 4, 3, 2, 1]
Output
[1, 2, 2, 3, 4, 4]
Duplicates are handled and appear in sorted order.