Skip to content

Bug Report for buy-and-sell-crypto #5593

@josevs99

Description

@josevs99

Bug Report for https://neetcode.io/problems/buy-and-sell-crypto

Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.

Image

as shown on the description

Returning Negative Profit
If prices only decrease, the maximum profit is 0 (don't trade), not a negative number. Always ensure the result is at least 0.

Unless I understanding it wrong if we have as input prices=[3,4,1] since prices only decrease expected output should be 0, not 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions