Odd, it looks like O(n^2) to me.
Odd, it looks like O(n^2) to me.
If you understand what you're doing, you're not learning anything.
The nested while loop looks like O(n^2), but at most you traverse both arrays once, leading to 2n time, or O(n).
If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein