Question bank › Prefix Sum
Dsa Prefix Sum Medium

Stock Price Fluctuation

Given an integer list representing daily stock prices of a company, write a function to find the maximum price increase that can be achieved by buying and then selling the stock over several days. The program should first calculate the daily gains and then find the maximum sum of any contiguous subarray of those gains. Input format: - A single line containing N (1 ≤ N ≤ 100000) followed by a list of N integers representing stock prices. Output format: - An integer representing the maximum increase in stock price that can be achieved. Example: Input: 5 100 200 150 300 250 Output: 150

Key concepts

prefix_sumarray_manipulationcumulative_sum

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.