I am confused. I am solving this problem on leetcode and I wrote this code where there's nested while loops. From the first look, one would think it is an O(N^2) solution, however, I am wondering if that is true since the inner while loop does not iterate over the entire array but just a part of it. Thus, I think it is O(N).
Please confirm my understanding
var removeDuplicates = function(nums) {
let i = 0, j = i + 1
while(i < nums.length - 1 && j < nums.length){
while(nums[i] == nums[j]){
nums.splice(j, 1)
}
j++
i++
}
return j
};