I was making a code in which I needed to compare elements of my array with another array.
But I was thinking that this would increase my time complexity from O(n) to O(n^2) as it was already inside one for loop, for the first array.
So I came up with a code like this, inside the parent for loop (with parameter i):
int m = 0;
int ele = array2[m];
if(array1[i] == ele)
count++;
m++;
But since the thing that is being done is same, only I have emitted a for loop, I was wondering that the time complexity indeed was O(n) or became O(n^2).
I also understand that this would only compare the same indexed elements and not all. I would appreciate if someone can part more information about this.