Stock span problem

sir why its failing test case 3

hello @YASHMATHURIA123
increase ur array (ans array ) size .
declare it like
int ans[n+1];

why sir ?? why we do that

can you sir please make changes in my code sir kyu ki output toh dono se same aa raha hai

tumhara logic sahi hai bro.
n ki value 10^6 tak ho sakti hai ,isilye array ka size badhane ko bol raha hu.

sir please tell me so that i will not make these silly mistakes in future sir ans[n+1] does not affect my output please tell sir

Hello @YASHMATHURIA123,

I have corrected your code:


Refer to the comments for better understanding.

Hope, this would help.