Quick actions

cmd+k|ctrl+k

Navigation

Languages

Nemo_Example

Snippet info

Language

JavaScript

Visibility

public

Author

dswiziard26

Created

2023-02-26T00:44:58.242342Z

Updated

2023-07-01T20:44:50.13859Z

const nemo = ['nemo'];
const large = new Array(1000).fill('nemo');

function findNemo(array) {
    let t0 = performance.now();
    for (let i =0; i <nemo.length; i++) {
        if (nemo[i] == 'nemo'){
            console.log('Found Nemo!');
        }
    }
    let t1 = performance.now();
    console.log('Call to Find Nemo took ' + (t1-t0)+' miliseconds');
}

findNemo(nemo);//O(n) --> Linear Time


const boxes = [55,88,44,65,456,123184,654]
function grabFirstTwoBoxes(boxes) {
    console.log(boxes[0]); //O(1)
    console.log(boxes[1]); //O(1)
    
}

grabFirstTwoBoxes(boxes) // O(2)
INFO