Doubt in time complexity for Increasing Temperature question

Hi team,
I have a doubt regarding time complexity for this Increasing Temperature question.
As per the solution provided, the time complexity of this question should be O(n) but since we are using two loop-

  1. for loop to iterate over array elements and
  2. while loop for finding next higher temperature & updating answer array
    So shouldn’t the time complexity be O(N2).

inner loop never run N times
either it run 2 times or 3 times on average
sum of times the inner loop run is N

you can see it other way round
every element is inserted once and poped once
so total time it run is 2*N so time complexity will be O(N)