Quick actions

cmd+k|ctrl+k

Navigation

Languages

Nemo

Snippet info

Language

JavaScript

Visibility

public

Author

fjbprofile

Created

2024-10-29T15:02:31.276624Z

Updated

2024-10-29T15:02:31.276624Z

// const nemo = ['nemo']
// const everyone = ['dory', 'bruce', 'marlin', 'nemo', 'gill', 'bloat', 'nigel',
// 'squirt', 'darla', 'hank'];
// const large = new Array(100).fill('nemo')

// function findNemo(array) {
//     for (let i = 0; i < array.length; i++) {
//         if (array[i] === 'nemo') {
//             console.log('Found NEMO!');
//         }
//     }
// }

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

//Constant time o(1)
const boxes = [0,1,2,3,4,5];

function logFirstTwoBoxes(boxes) {
    console.log(boxes[0]); //O(1)
    console.log(boxes[1]); //O(1)
}

logFirstTwoBoxes(boxes) //O(2) (2 lines on the graph, but still flat)
INFO