I am learning data structure and pretty new to this game. I know a single loop running for n-iteration has O(n) time complexity. But if I use a splice
inside the for loop, is it going to be O(n2) time complexity? I am positive it's O(n2) but want to make sure.
Here is the sample code that I was working on:
var createTargetArray = function(nums, index) {
let target = []
for (let i=0; i< index.length; i++){
let idx = index[i]
target.splice(idx,0,nums[i])
}
return target
};