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

Programming Exercises

Create a method to find the maximum profit from stock prices where you can only buy and sell once.

Medium

Problem Statement

Create a method to find the maximum profit from stock prices where you can only buy and sell once.

Sample Input

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

Sample Output

5

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
# Predefined stock prices prices = [7, 1, 5, 3, 6, 4] # 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
5