Quick Overview

Given one stock's price on each of several consecutive days, compute the maximum profit from buying one share and selling it on a strictly later day, or zero if no trade makes money. It tests efficient reasoning over an array under large input bounds and careful handling of edge cases such as falling prices or a single day.

Maximum Profit from One Stock Purchase and a Later Sale

Company: Xiaohongshu

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Overview: Given one stock's price on each of several consecutive days, compute the maximum profit from buying one share and selling it on a strictly later day, or zero if no trade makes money. It tests efficient reasoning over an array under large input bounds and careful handling of edge cases such as falling prices or a single day.

Loading…