DCGAME - Editorial

Your code doesn’t calculate the frequencies correctly. See editorial for help.

To identify it as the stock span problem you either need to be familiar with it or simply be able to rediscover the solution on your own (it’s not too hard really). But if you didn’t know, you can still solve it using segment trees / binary search trees, albeit at O(N log N) time.