PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Coinbase

Maximize profit with transaction fees

Last updated: Mar 29, 2026

Quick Overview

This question evaluates algorithm design skills, specifically understanding of dynamic programming and greedy strategies for optimizing profit under transaction fees, along with stateful decision-making and handling cost constraints.

  • Medium
  • Coinbase
  • Coding & Algorithms
  • Software Engineer

Maximize profit with transaction fees

Company: Coinbase

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

You are given an array prices where prices[i] is the price of a stock on day i and an integer fee representing the commission charged when you sell. You may complete as many transactions as you like (buy one and later sell one share), but you must sell before you buy again and can hold at most one share at a time. Return the maximum net profit achievable. Describe your algorithm and analyze time and space complexity. Follow-ups: How would the solution change if the fee were charged on both buy and sell, or if multiple shares could be held concurrently?

Quick Answer: This question evaluates algorithm design skills, specifically understanding of dynamic programming and greedy strategies for optimizing profit under transaction fees, along with stateful decision-making and handling cost constraints.

Related Interview Questions

  • Implement an In-Memory Database - Coinbase (hard)
  • Implement a Coin-Constrained Jump Strategy - Coinbase (hard)
  • Implement Game Physics and Block Mining - Coinbase (hard)
  • Compute Total Manual Distance - Coinbase (medium)
  • Implement a Flappy Bird Jump Agent - Coinbase
Coinbase logo
Coinbase
Sep 6, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
12
0

You are given an array prices where prices[i] is the price of a stock on day i and an integer fee representing the commission charged when you sell. You may complete as many transactions as you like (buy one and later sell one share), but you must sell before you buy again and can hold at most one share at a time. Return the maximum net profit achievable. Describe your algorithm and analyze time and space complexity. Follow-ups: How would the solution change if the fee were charged on both buy and sell, or if multiple shares could be held concurrently?

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Coinbase•More Software Engineer•Coinbase Software Engineer•Coinbase Coding & Algorithms•Software Engineer 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.