Stock Span Problem Problem

Stock Span Problem Problem — ExecCode Easy DSA Practice

Solve the Stock Span Problem problem on ExecCode. Free online easy DSA practice in Stack. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given the input needed to solve Stock Span Problem. Your task is to compute the required answer and return spans space-separated. n, then n prices.

Examples

Input {"nums": [10, 4, 5, 90, 120, 80]}; Output 1 1 2 4 5 1. Input {"nums": [80, 70, 60, 85, 100]}; Output 1 1 1 4 5. Input {"nums": [10, 20, 30, 40, 50, 60, 70, 80]}; Output 1 2 3 4 5 6 7 8

Constraints

Monotonic stack O(n)

Practice Stock Span Problem free on ExecCode. Browse DSA problems, topic map, and placement guides.