PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Two Sigma

Maximize profit from one stock trade

Last updated: Mar 29, 2026

Quick Overview

This question evaluates algorithmic problem-solving skills with emphasis on array processing, numeric optimization, and time/space complexity analysis in the coding & algorithms domain. It is commonly asked to assess practical implementation ability and efficiency trade-offs under input-size constraints, and the level of abstraction is practical application rather than purely conceptual reasoning.

  • nan
  • Two Sigma
  • Coding & Algorithms
  • Data Scientist

Maximize profit from one stock trade

Company: Two Sigma

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: nan

Interview Round: Technical Screen

## Problem You are given an integer array `prices` where `prices[i]` is the price of a stock on day `i`. You may complete **at most one transaction**: choose a day to buy one share and a later day to sell that share. Return the **maximum profit** you can achieve. If no profit is possible, return `0`. ### Input - `prices`: array of integers, length `n` ### Output - An integer: maximum achievable profit ### Constraints - `1 <= n <= 2 * 10^5` - `0 <= prices[i] <= 10^9` ### Example - Input: `prices = [7,1,5,3,6,4]` - Output: `5` (buy at `1`, sell at `6`)

Quick Answer: This question evaluates algorithmic problem-solving skills with emphasis on array processing, numeric optimization, and time/space complexity analysis in the coding & algorithms domain. It is commonly asked to assess practical implementation ability and efficiency trade-offs under input-size constraints, and the level of abstraction is practical application rather than purely conceptual reasoning.

Related Interview Questions

  • Implement Price-Time Order Matching - Two Sigma (medium)
  • Compute Piecewise Linear Interpolation - Two Sigma (medium)
  • Implement an In-Memory Database - Two Sigma (hard)
  • Merge two sorted linked lists - Two Sigma (hard)
  • Merge Two Sorted Lists - Two Sigma (hard)
Two Sigma logo
Two Sigma
Jan 22, 2026, 12:00 AM
Data Scientist
Technical Screen
Coding & Algorithms
6
0
Loading...

Problem

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

You may complete at most one transaction: choose a day to buy one share and a later day to sell that share.

Return the maximum profit you can achieve. If no profit is possible, return 0.

Input

  • prices : array of integers, length n

Output

  • An integer: maximum achievable profit

Constraints

  • 1 <= n <= 2 * 10^5
  • 0 <= prices[i] <= 10^9

Example

  • Input: prices = [7,1,5,3,6,4]
  • Output: 5 (buy at 1 , sell at 6 )

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Two Sigma•More Data Scientist•Two Sigma Data Scientist•Two Sigma Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ 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.