Skip to content

fix: resolve #395 — Add Best Time to Buy and Sell Stock in C++ - #412

Open
Nam0101 wants to merge 2 commits into
xthxr:mainfrom
Nam0101:contribai/improve/quality/implement-best-time-to-buy-and-sell-stoc
Open

fix: resolve #395 — Add Best Time to Buy and Sell Stock in C++#412
Nam0101 wants to merge 2 commits into
xthxr:mainfrom
Nam0101:contribai/improve/quality/implement-best-time-to-buy-and-sell-stoc

Conversation

@Nam0101

@Nam0101 Nam0101 commented Jul 13, 2026

Copy link
Copy Markdown

Summary

fix: resolve #395 — Add Best Time to Buy and Sell Stock in C++

Problem

Severity: Medium | File: C++/Greedy/best_time_to_buy_and_sell_stock.cpp

File already exists under Greedy. Ensure complete O(n) one-pass solution: track min price seen, max profit = max(price - minPrice). Return 0 if no profit. Include problem statement comment, function, and small main with sample cases.

Solution

Replace/fill with:

Changes

  • C++/Greedy/best_time_to_buy_and_sell_stock.cpp (modified)
  • C++/Leetcode_Solutions/121-best-time-to-buy-and-sell-stock/best-time-to-buy-and-sell-stock.cpp (new)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

Note: this change was drafted with AI assistance and reviewed locally before submission.

Nam0101 added 2 commits July 13, 2026 12:03
Fixes xthxr#395

Signed-off-by: Nguyen Van Nam <nam.nv205106@gmail.com>
Fixes xthxr#395

Signed-off-by: Nguyen Van Nam <nam.nv205106@gmail.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Best Time to Buy and Sell Stock in C++

1 participant