I understand what you're saying. I found some of the questions very confusing but this question was not so bad.
But i had to read multiple times this line :
"Also given an integer k, you need to output in which day there exists two flowers in the status of blooming, and also the number of flowers between them is k and these flowers are not blooming."
f is a list that its index means position and f[i] means the day that flower i opens.
The stack is strictly decreasing, in terms of f[i]. When a new index j arrives, we know for every index x ( stack[-1] < x < j) f[x] > f[j] and f[x] > f[stack[-1]]. This means for every flower x, it opened after j and stack[-1]. So if there is k spots between j and stack[-1], this is a valid result.
How do we keep the stack strictly decreasing? Before appending the new index j, we pop every index x that f[x] > f[j].
It took me a while to understand. I hope this will help.
@mark72 No. I mean that we should go through all the N slots to find the earliest day which meets the conditions. When all days[x1 + i] > min(days[x1], days[x1 + k + 1]) s.t. 0 < i <= k, max(days[x1], days[x1 + k + 1]) may be a probable solution. Still, you have go ahead to see whether there is someday earlier.