Selection Sort - Coding Interview Question - JavaScript

preview_player
Показать описание


Here is a step by step explanation of the selection sort algorithm.

Time Complexity: O(n^2)
Space Complexity: O(1)

JavaScript

0:00 Explanation
3:44 Code

#softwaredeveloper #coding #leetcode
Рекомендации по теме
Комментарии
Автор

Why is this a bad code?


let selectionSort = (a) => {
for(let i = 0; i < a.length; i++) {

let m = a[i]

for(let j = i; j < a.length; j++) {

if(a[j] < m) {

m=a[j]
a[j]=a[i]
a[i] = m
}

}

MrArchy
join shbcf.ru