Two passes through an array O(n) or O(2n)
<p>I was on interview cake practicing some questions, and on question <a href="https://www.interviewcake.com/question/java/product-of-other-numbers" rel="nofollow noreferrer">2</a> the solution given uses two separate for loops (not nested) and the solution provider claims that he/she solved it in O(n) time. From my understanding that would be O(2n) time. Am I wrong in thinking this, or did the solution provider make a mistake?</p>
<p>Excerpt from interview cake :
<a href="https://i.stack.imgur.com/sAbpp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sAbpp.png" alt="enter image description here" /></a></p>