Algorithm Basics
Algorithm Basics
Section titled “Algorithm Basics”An algorithm is a finite sequence of steps used to solve a problem.
Example
Section titled “Example”function findMax(arr) { let max = arr[0];
for (let i = 1; i < arr.length; i++) { if (arr[i] > max) { max = arr[i]; } }
return max;}Time: O(n) Space: O(1)