Please correct me if i’m wrong, but I think you made a mistake in your last example:

It can’t be more simplified, it should remain O(n+m) because you have no prior knowledge of the lengths of the arrays. m can be much bigger than n, and vice versa.

Please correct me if i’m wrong, but I think you made a mistake in your last example:

It can’t be more simplified, it should remain O(n+m) because you have no prior knowledge of the lengths of the arrays. m can be much bigger than n, and vice versa.

That’s right but the cost still grows linearly with the size of the input. So you can simplify the runtime complexity as O(*n*) with *n* being the length of the `numbers`

array plus the length of the `names`

array.

1 Like

That’s what i figured, but i think it would be better if the different lengths were denoted as *a* and *b* instead, just to avoid confusion.