execute method
Execute the algorithm on the given input.
This method should be:
- Fast: optimized for the hot path with minimal allocations
- Pure: no side effects (unless documented otherwise)
- Predictable: consistent behavior for the same input
Preconditions:
- canApply(input, hint) must return true
- Input must meet the strategy's requirements (e.g., sorted if requiresSorted)
The caller is responsible for ensuring preconditions are met.
Implementation
@override
List<int> execute(List<int> input) {
if (input.isEmpty || input.length == 1) return List.from(input);
final result = List<int>.from(input);
_quickSort(result, 0, result.length - 1);
return result;
}