Want quant roles sent to your inbox?

Get quant job listings, interview prep resources, and industry news delivered to you for free.

No spam. Unsubscribe anytime.

Maximum Profit Trades

Programming Interview
Questions

← Back

Maximum Profit Trades

You are given a list of daily stock prices where prices[i] is the price of a given stock on the i-th day.

Once you have bought, you must sell in order to buy again. You cannot short sell (i.e. sell and go into negative holdings).

Write a function maximum_profit(prices) to return the maximum profit you can achieve.

Input:

  • prices: A list of numbers, denoting a stock price over time.

Output: The value gained from all maximum profit trades.

Your solution should run in Linear time O(n).

Not Completed

Completed!

maximum_profit.py

Tests - to submit your code!

symbol symbol

Efficiency

symbol symbol

Test Case 1

symbol symbol

Test Case 2

symbol symbol

Test Case 3

symbol symbol

Test Case 4

symbol symbol

Test Case 5

symbol symbol

Test Case 6

symbol symbol

Test Case 7

symbol symbol

Test Case 8

symbol symbol

Test Case 9

symbol symbol

Test Case 10

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

symbol Submit to See Results

Join our Newsletter and Receive the Latest Updates!

Main Links

Academy Trade Courses Assessments Interview Prep Contact Us

Social Media

Facebook Instagram YouTube

Legal

Terms and Conditions

Talent Acquisition

Looking to hire exceptional quant talent?

© 2026 EverythingQuant. All Rights Reserved.