What is the time complexity of this algorithm?

function removeDup(array) {
    var newArray = [];
        for(var i = 0; i < array.length;iPP){
            if(newArray.indexOf(array[i]) == -1 ) {
                newArray.push(array[i]);
            }
        }
    return newArray;
}
Is there an indexOf, inside the

loop whose time complexity is between O (n) and O (n ^ 2)?

Mar.22,2021

O (n ^ 2)
the actual run time complexity is between O (n) and O (n ^ 2), but the time complexity is described as the maximum, that is, O (n ^ 2)


array. This is a layer of for loop that determines that it should be

between O (N) and o (n ^ 2).
Menu