PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Flipster

Compute max profit from one stock trade

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's understanding of array-based data processing, difference maximization, and basic algorithmic optimization for time-series inputs. It is commonly asked in Coding & Algorithms interviews to assess fundamental practical programming ability and attention to edge cases (e.g.

  • easy
  • Flipster
  • Coding & Algorithms
  • Software Engineer

Compute max profit from one stock trade

Company: Flipster

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

Given an integer array `prices` where `prices[i]` is the stock price on day `i`, compute the **maximum profit** you can achieve by choosing **at most one** day to buy and a later day to sell. - You may complete **0 or 1** transaction. - You must buy before you sell. ### Input - `prices`: array of integers, `n >= 1` ### Output - Maximum possible profit (integer). ### Example - Input: `[7, 1, 5, 3, 6, 4]` - Output: `5` (buy at 1, sell at 6) ### Edge cases - Prices always decreasing → return `0`.

Quick Answer: This question evaluates a candidate's understanding of array-based data processing, difference maximization, and basic algorithmic optimization for time-series inputs. It is commonly asked in Coding & Algorithms interviews to assess fundamental practical programming ability and attention to edge cases (e.g.

Flipster logo
Flipster
Feb 12, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
1
0

Given an integer array prices where prices[i] is the stock price on day i, compute the maximum profit you can achieve by choosing at most one day to buy and a later day to sell.

  • You may complete 0 or 1 transaction.
  • You must buy before you sell.

Input

  • prices : array of integers, n >= 1

Output

  • Maximum possible profit (integer).

Example

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

Edge cases

  • Prices always decreasing → return 0 .

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Flipster•More Software Engineer•Flipster Software Engineer•Flipster Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

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