Refer to the code link below
Sample test case passed successfully
Refer to the code link below
Sample test case passed successfully
@ambuj_0909
hello Ambuj
ur logic and implementation is not correct.
pls once check the span definition
to find span for ith index
a) first we need to pop all such indices where arr[stk.top()] <= arr[i] (make sure stack is not empty)
b) after that check whether stack is empty or not if it is empty then span will be i+1 otherwise span will be i-stk.top()
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.