Insertion Sort

Question (LC.463)

Given an integer array, sort it in ascending order. Use selection sort, bubble sort, insertion sort or any O(n^2) algorithm.

Example

Input: [3, 2, 1, 4, 5]
Return: [1, 2, 3, 4, 5]

Analysis

Insert each element into the "right" place.

results matching ""

    No results matching ""