Skip to content

fix: fill the problem 309 cooldown profits from the end - #5945

Draft
yanglbme wants to merge 1 commit into
mainfrom
cursor/fix-lc309-dp-d5cc
Draft

yanglbme wants to merge 1 commit into
mainfrom
cursor/fix-lc309-dp-d5cc

Conversation

@yanglbme

@yanglbme yanglbme commented Oct 2, 2026

Copy link
Copy Markdown
Member

Summary

Problem 309 method 1 always recurses to the next day. With up to 5,000 prices that chain overflows Python's call stack. Python, Java, C++, Go, and TypeScript now fill the same holding-state table from the end. Methods 2 and 3 still use the forward formulation.

Type

  • New solution
  • Update solution
  • Docs
  • Other

Checklist

For new or updated solutions:

  • README.md / README_EN.md follow solution/template.md
  • If a Thinking block is added, it sits after the method heading, is non-empty, and matches the code in the repo (naive idea vs constraints, bottleneck, key observation, why this method). Thinking is optional.
  • All languages implement the same algorithm; unrelated Solution.* files and code tabs are unchanged
  • Code is formatted as described in AGENTS.md
Open in Web Open in Cursor 

@idoocs idoocs added core team Issues or pull requests from core team cpp Issues or Pull requests relate to .cpp code go Issues or Pull requests relate to .go code java Issues or Pull requests relate to .java code md Issues or Pull requests relate to .md files py Issues or Pull requests relate to .py code ts Issues or Pull requests relate to .ts code labels Oct 2, 2026
The recursive solution stays in place. The iterative version is
added as a separate solution.
@cursor
cursor Bot force-pushed the cursor/fix-lc309-dp-d5cc branch from 6924bf4 to 3b10825 Compare October 3, 2026 16:16

This branch has not been deployed

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

Labels

core team Issues or pull requests from core team cpp Issues or Pull requests relate to .cpp code go Issues or Pull requests relate to .go code java Issues or Pull requests relate to .java code md Issues or Pull requests relate to .md files py Issues or Pull requests relate to .py code ts Issues or Pull requests relate to .ts code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants