Trick about this question is that variable 'i' is shared and variable j is global.
Therefore, outer loop will only iterate once because on second iteration, i will be 2n due to inner for loop.
Also, while loop will also run for just once. Again, during second iteration, j will be n and hence condition will evaluate to false.
So this code runs for=>
2n(inner for loop) + n(while loop)
=> O(n)