Stack span Problem

Test Case 2 giving wrong answer


here u can look at my simple stack based solution of this problem
it takes O(N) time as well space