Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a program to find the maximum profit in a stock market given stock prices for each day.

Hard

Problem Statement

Write a program to find the maximum profit in a stock market given stock prices for each day.

Sample Input

[7, 1, 5, 3, 6, 4]

Sample Output

Maximum Profit: 5

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
function maxProfit(prices: number[]): number { // Your logic here }
Log in or sign up to run or submit your code.Log inSign up
Input
[7, 1, 5, 3, 6, 4]
Expected Output
Maximum Profit: 5