O(n)

Run Settings
LanguageJavaScript
Language Version
Run Command
const smallArray = ['nemo']; const mediumArray = new Array(10).fill('nemo'); const largeArray = new Array(1e3).fill('nemo'); function findNemo(array=[]){ console.time(`time took to find nemo is `) for(i=0;i<array.length;i++){ if(array[i] === 'nemo'){ console.log('nemo found') } } console.timeEnd(`time took to find nemo is `) } findNemo(smallArray) findNemo(mediumArray) findNemo(largeArray) //O(n) | O(fish) --> Linear Time - As the size of elements increases, no of operations will increase linearly
Editor Settings
Theme
Key bindings
Full width
Lines