Time Complexity

What will be the time complexity for this question ?
In my opinion it should be O(4n) = O(n).
Pls let me know if I am right.

Hello @vishakha_narang I think yes it should be the only time complexity.

I got 4n as- 2n for collision detection . For eg for test case: 1,2,3,4,5,-6 we traverse elements two times.

and 2n for reversal of the order of numbers using the stack . Want to confirm if 2n is right for collision detection part

@vishakha_narang yes i think that is right.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.