# Stock Span Problem

Problem Link: <https://practice.geeksforgeeks.org/problems/stock-span-problem-1587115621/1>

```python
class Solution:
    
    #Function to calculate the span of stockâ€™s price for all n days.
    def calculateSpan(self,nums,n):
        #code here
        
        s=[]
        ans=[]
        for i in range(n):
            if(len(s)==0):
                ans.append(i-(-1))
            else:
                if(nums[s[-1]]>nums[i]):
                    ans.append(i-s[-1])
                else:
                    while(len(s)>0 and nums[s[-1]]<=nums[i]):
                        s.pop()
                    if(len(s)==0):
                        ans.append(i-(-1))
                    else:
                        ans.append(i-s[-1])
            s.append(i)
        
        return ans
```
