Katkat

Maximize profit with transaction fee

CoinbaseSoftware Engineer · Onsite

Last updated

This interview question evaluates algorithm design, data structures, correctness, complexity, edge cases, and implementation details in a realistic interview setting. A strong answer for Maximize profit with transaction fee states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.

Given an array of daily stock prices and a fixed transaction fee charged on each sell, compute the maximum profit achievable with any number of buy–sell transactions. Provide an O(n) time, O(

  1. or O(n) space algorithm, prove correctness, and describe how you would handle edge cases such as empty input or strictly decreasing prices.