PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Squarepoint

Maximize profit from one or many stock trades

Last updated: Mar 29, 2026

Quick Overview

This question evaluates algorithmic problem-solving skills, particularly efficient array processing and profit-optimization across single-transaction and multiple-transaction variants, along with time and space complexity analysis.

  • hard
  • Squarepoint
  • Coding & Algorithms
  • Data Scientist

Maximize profit from one or many stock trades

Company: Squarepoint

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are given an integer array `prices` where `prices[i]` is the price of a stock on day `i` (0-indexed). Answer the following two subproblems: 1. **Single transaction** - You may complete at most **one** transaction: choose one day to buy and a later day to sell (must buy before you sell). - You are not allowed to short-sell. - Return the **maximum profit** you can achieve. If you cannot make any profit, return `0`. 2. **Multiple transactions** - You may complete **as many transactions as you like** (i.e., buy and sell multiple times), but you **cannot hold more than one share at a time** (you must sell the stock before you buy again). - You are not allowed to short-sell. - Return the **maximum total profit** you can achieve. Assume: - `1 <= n <= 10^5`, where `n` is the length of `prices`. - `0 <= prices[i] <= 10^4`. Design efficient algorithms for both subproblems and analyze their time and space complexity.

Quick Answer: This question evaluates algorithmic problem-solving skills, particularly efficient array processing and profit-optimization across single-transaction and multiple-transaction variants, along with time and space complexity analysis.

Related Interview Questions

  • Implement EMA Crossovers and Root Solvers - Squarepoint (medium)
  • Solve two coding assessment tasks - Squarepoint (hard)
  • Parse payroll file and answer queries - Squarepoint (medium)
  • Maximize revenue from inventory sales - Squarepoint (medium)
Squarepoint logo
Squarepoint
Nov 7, 2025, 12:00 AM
Data Scientist
Technical Screen
Coding & Algorithms
2
0

You are given an integer array prices where prices[i] is the price of a stock on day i (0-indexed).

Answer the following two subproblems:

  1. Single transaction
    • You may complete at most one transaction: choose one day to buy and a later day to sell (must buy before you sell).
    • You are not allowed to short-sell.
    • Return the maximum profit you can achieve. If you cannot make any profit, return 0 .
  2. Multiple transactions
    • You may complete as many transactions as you like (i.e., buy and sell multiple times), but you cannot hold more than one share at a time (you must sell the stock before you buy again).
    • You are not allowed to short-sell.
    • Return the maximum total profit you can achieve.

Assume:

  • 1 <= n <= 10^5 , where n is the length of prices .
  • 0 <= prices[i] <= 10^4 .

Design efficient algorithms for both subproblems and analyze their time and space complexity.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Squarepoint•More Data Scientist•Squarepoint Data Scientist•Squarepoint Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.