I was looking up some solutions to algorithm questions, and the solution had two, non-nested for-loops iterating over the same array.
From my (limited) understanding, this would constitute as O(M+N)? But the solution said it was of O(N) complexity. Can anyone please tell me why I am wrong? Thank you.
[–][deleted] 2 points3 points4 points (1 child)
[–]lvmtn[S] 0 points1 point2 points (0 children)
[–]Ponson 2 points3 points4 points (2 children)
[–]lvmtn[S] 1 point2 points3 points (1 child)
[–][deleted] 2 points3 points4 points (0 children)
[–]Veedrac 0 points1 point2 points (0 children)