-
Notifications
You must be signed in to change notification settings - Fork 1
Add solutions and explanations for problems 3178, 3179, 3212, 3244, 3276 #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideAdds a new dynamic programming solution and detailed explanation for problem 3573 (stock trading with up to k transactions including short selling), and registers the problem in the book-sets metadata list. Class diagram for dynamic programming solution to problem 3573classDiagram
class Solution {
+maximumProfit(prices, k) int
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Caution Review failedThe pull request is closed. Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds Husky/prettier formatting tooling, updates .gitignore, reformats a JSON dataset, adds package.json scripts and devDependencies, and introduces multiple new problem solution Python files with corresponding explanation Markdown files. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- The PR title/description talk about problems 3178, 3179, 3212, 3244, and 3276, but the diff only adds content for problem 3573, so please align the PR metadata with the actual changes or include the missing files.
- In
maximumProfit, the DP state indexing is a bit unintuitive (e.g.,resis lengthk+1whilebought/soldare lengthkand usej-1), so consider renaming variables or slightly restructuring the loops to make the transaction index semantics clearer.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The PR title/description talk about problems 3178, 3179, 3212, 3244, and 3276, but the diff only adds content for problem 3573, so please align the PR metadata with the actual changes or include the missing files.
- In `maximumProfit`, the DP state indexing is a bit unintuitive (e.g., `res` is length `k+1` while `bought`/`sold` are length `k` and use `j-1`), so consider renaming variables or slightly restructuring the loops to make the transaction index semantics clearer.
## Individual Comments
### Comment 1
<location> `explanations/3573/en.md:11-20` </location>
<code_context>
+- **Space Complexity:** O(k) for storing the DP arrays (res, bought, sold) of size k.
</code_context>
<issue_to_address>
**issue:** Clarify the described sizes of the DP arrays to match the example initialization.
The example initializes `res` with `k+1` entries (for 0..k completed transactions), while `bought` and `sold` have length `k`. Please adjust the description so it matches this (e.g., explicitly call out `res` as size `k+1` and `bought`/`sold` as size `k`).
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| - **Space Complexity:** O(k) for storing the DP arrays (res, bought, sold) of size k. | ||
| - **Edge Case:** If k is 0, we cannot make any transactions, so the profit is 0. | ||
|
|
||
| **1.2 High-level approach:** | ||
|
|
||
| The goal is to maximize profit by choosing the best sequence of transactions (normal or short selling) up to k transactions. We use dynamic programming to track the best profit at each stage of transaction completion. | ||
|
|
||
| **1.3 Brute force vs. optimized strategy:** | ||
|
|
||
| - **Brute Force:** Try all possible combinations of transactions (normal or short) at each day, which would be exponential in complexity O(2^(n*k)). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Clarify the described sizes of the DP arrays to match the example initialization.
The example initializes res with k+1 entries (for 0..k completed transactions), while bought and sold have length k. Please adjust the description so it matches this (e.g., explicitly call out res as size k+1 and bought/sold as size k).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
♻️ Duplicate comments (1)
explanations/3573/en.md (1)
11-11: Clarify DP array sizes.The space complexity description states "size k" but
resis actually sizek+1(for 0..k completed transactions).
🧹 Nitpick comments (1)
solutions/3276/01.py (1)
10-11: Use set comprehension and remove redundantlist()call.Minor style improvements for more idiomatic Python.
- value_set = set([grid[r][c] for r in range(rows) for c in range(cols)]) - value_list = sorted(list(value_set), reverse=True) + value_set = {grid[r][c] for r in range(rows) for c in range(cols)} + value_list = sorted(value_set, reverse=True)
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (17)
.gitignore(1 hunks).husky/pre-commit(1 hunks)data/book-sets.json(1 hunks)explanations/3178/en.md(1 hunks)explanations/3179/en.md(1 hunks)explanations/3212/en.md(1 hunks)explanations/3244/en.md(1 hunks)explanations/3276/en.md(1 hunks)explanations/3573/en.md(1 hunks)package.json(1 hunks)solutions/3178/01.py(1 hunks)solutions/3179/01.py(1 hunks)solutions/3212/01.py(1 hunks)solutions/3213/01.py(1 hunks)solutions/3244/01.py(1 hunks)solutions/3276/01.py(1 hunks)solutions/3573/01.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
solutions/3179/01.py (1)
visualizations/3623/01.jsx (1)
MOD(39-39)
🪛 LanguageTool
explanations/3179/en.md
[style] ~9-~9: As an alternative to the over-used intensifier ‘very’, consider replacing this phrase.
Context: ...between 1 and 1000. The values can grow very large, so we need modulo 10^9 + 7. - **Time C...
(EN_WEAK_ADJECTIVE)
explanations/3573/en.md
[style] ~30-~30: This is not the usual sequence for adjectives that have no special emphasis.
Context: ...e). 5. Update sold[j-1] by starting a new short transaction (sell at current price). 6....
(EN_ADJ_ORDER)
🪛 markdownlint-cli2 (0.18.1)
explanations/3178/en.md
38-38: Spaces inside emphasis markers
(MD037, no-space-in-emphasis)
38-38: Spaces inside emphasis markers
(MD037, no-space-in-emphasis)
🪛 Ruff (0.14.8)
solutions/3213/01.py
2-2: Undefined name List
(F821)
2-2: Undefined name List
(F821)
solutions/3244/01.py
3-3: Undefined name List
(F821)
3-3: Undefined name List
(F821)
4-4: Undefined name List
(F821)
solutions/3276/01.py
2-2: Undefined name List
(F821)
2-2: Undefined name List
(F821)
solutions/3573/01.py
2-2: Undefined name List
(F821)
solutions/3212/01.py
2-2: Undefined name List
(F821)
2-2: Undefined name List
(F821)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Sourcery review
- GitHub Check: Cursor Bugbot
🔇 Additional comments (16)
.gitignore (1)
15-15: LGTM!Adding
node_modules/to.gitignoreis the correct approach for Node.js projects with npm dependencies.explanations/3276/en.md (1)
1-61: LGTM!The explanation is well-structured with clear problem restatement, complexity analysis, and a concrete example walkthrough that aligns with the solution approach.
solutions/3179/01.py (1)
1-12: LGTM!The prefix sum implementation is correct and efficiently uses in-place updates with proper modulo arithmetic to prevent overflow.
package.json (1)
1-10: LGTM!The Husky and Prettier setup provides automated JSON formatting on pre-commit, which will help maintain consistent formatting across the repository.
solutions/3213/01.py (1)
3-18: LGTM!The dynamic programming logic correctly computes the minimum cost to construct the target string using the available words, with proper handling of unreachable states.
explanations/3178/en.md (1)
1-60: LGTM!The explanation clearly describes the ball-passing simulation approach with proper complexity analysis and a concrete example walkthrough.
solutions/3178/01.py (1)
1-18: LGTM!The ball-passing simulation correctly uses period-based optimization and properly handles direction reversal at boundaries.
solutions/3244/01.py (1)
9-20: LGTM!The linked list approach is clean and efficient. The amortized O(n + q) complexity is achieved since each node is popped at most once.
explanations/3244/en.md (1)
1-59: LGTM!The explanation is clear, well-structured, and accurately describes the linked list approach. The trace walkthrough effectively demonstrates the algorithm.
solutions/3276/01.py (1)
19-38: LGTM!The memoized DFS correctly explores all valid cell selections. Processing values in descending order with row exclusion tracking is an effective approach.
explanations/3212/en.md (2)
10-11: Verify the time complexity claim.The stated O(m * n * min(m,n)) complexity assumes efficient X-detection, but checking each submatrix for the presence of 'X' could be O(m*n) per submatrix, resulting in O(m² * n²) overall. Consider clarifying or using a prefix sum for 'X' count to achieve the claimed complexity.
44-62: LGTM!The trace walkthrough accurately demonstrates the algorithm with the example input.
explanations/3179/en.md (1)
1-61: LGTM!The explanation accurately describes the prefix sum approach, and the trace walkthrough correctly demonstrates the algorithm progression.
explanations/3573/en.md (1)
47-75: LGTM!The trace walkthrough is comprehensive and correctly demonstrates the DP state transitions for the example.
solutions/3573/01.py (1)
12-26: LGTM!The DP transitions correctly handle both normal and short-selling transactions. Processing
jfromkdown to1properly avoids using updated values within the same price iteration.data/book-sets.json (1)
1-224: Confirm intended placement ofuseLatestExplanationfield.The
useLatestExplanation: truefield is present only on the "All-TODO" object (line 222) and absent from other book set objects ("LeetCode 75", "LeetCode Top 150", "Top 100 Liked", "All", "Visualization"). Please verify whether this selective placement is intentional or if the field should be consistently applied across all objects.
.husky/pre-commit
Outdated
| npm run format:json | ||
| git add 'data/**/*.json' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling to prevent staging if formatting fails.
The commands execute sequentially without error handling. If npm run format:json fails, git add will still execute, potentially staging files in an inconsistent state.
Additionally, auto-staging all JSON files under data/** may stage unintended changes beyond the formatted files. Consider whether this behavior is desired.
Apply this diff to add error handling:
#!/bin/sh
-npm run format:json
-git add 'data/**/*.json'
+npm run format:json && git add 'data/**/*.json'Or use explicit error handling:
#!/bin/sh
+set -e
npm run format:json
git add 'data/**/*.json'📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| npm run format:json | |
| git add 'data/**/*.json' | |
| npm run format:json && git add 'data/**/*.json' |
🤖 Prompt for AI Agents
.husky/pre-commit lines 1-2: the hook runs `npm run format:json` followed by
`git add 'data/**/*.json'` without checking for errors or limiting staged files;
ensure the hook aborts if formatting fails and only stages files actually
modified by the formatter. Update the script to run the formatter and
immediately check its exit status (or use shell &&) so that `git add` runs only
on success; replace the broad glob add with adding only files changed by the
formatter (e.g., capture stdout/changed paths or use `git status
--porcelain`/`git add --patch` to stage explicit files) and exit non-zero on any
formatting failure to prevent committing inconsistent files.
| @@ -0,0 +1,2 @@ | |||
| npm run format:json | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing shebang line will prevent hook execution.
Git hooks require a shebang line (e.g., #!/bin/sh or #!/usr/bin/env bash) as the first line to specify the interpreter. Without it, the hook may fail to execute or behave unpredictably.
Apply this diff to add the shebang:
+#!/bin/sh
npm run format:json
git add 'data/**/*.json'📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| npm run format:json | |
| #!/bin/sh | |
| npm run format:json |
🤖 Prompt for AI Agents
.husky/pre-commit around lines 1-1: the hook is missing a shebang so the
interpreter is undefined and the hook may not run; add a shebang as the very
first line (for example use /usr/bin/env bash or /bin/sh) so the hook runs with
a defined shell, leaving the existing npm run format:json line intact and ensure
the file remains executable.
|
|
||
| Let's use the example input: `n = 3`, `k = 5`. | ||
|
|
||
| - Period = 2 * (3 - 1) = 2 * 2 = 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix markdown formatting.
Line 38 has spaces inside emphasis markers. Remove the spaces for proper markdown formatting.
Expected format:
- Period = 2 * (3 - 1) = 2 * 2 = 4🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
38-38: Spaces inside emphasis markers
(MD037, no-space-in-emphasis)
38-38: Spaces inside emphasis markers
(MD037, no-space-in-emphasis)
🤖 Prompt for AI Agents
In explanations/3178/en.md around line 38, the markdown uses emphasis markers
with spaces inside them; remove the spaces immediately inside the asterisks or
underscores so the line reads a properly formatted list item (e.g., "- Period =
2 * (3 - 1) = 2 * 2 = 4") ensuring no spaces between the marker and the text.
| class Solution: | ||
| def numberOfSubmatrices(self, grid: List[List[str]]) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing import for List.
The List type hint is used but not imported from the typing module, which will cause a NameError at runtime.
Apply this diff to add the required import:
+from typing import List
+
class Solution:
def numberOfSubmatrices(self, grid: List[List[str]]) -> int:📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| class Solution: | |
| def numberOfSubmatrices(self, grid: List[List[str]]) -> int: | |
| from typing import List | |
| class Solution: | |
| def numberOfSubmatrices(self, grid: List[List[str]]) -> int: |
🧰 Tools
🪛 Ruff (0.14.8)
2-2: Undefined name List
(F821)
2-2: Undefined name List
(F821)
🤖 Prompt for AI Agents
In solutions/3212/01.py around lines 1 to 2, the function signature uses the
List type hint but List is not imported; add the missing import by adding "from
typing import List" at the top of the file so the type annotation resolves and
avoids a NameError.
| # Check if this submatrix contains at least one X | ||
| has_x = False | ||
| for x in range(i + 1): | ||
| for y in range(j + 1): | ||
| if grid[x][y] == 'X': | ||
| has_x = True | ||
| break | ||
| if has_x: | ||
| break | ||
|
|
||
| if not has_x: | ||
| continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optimize X-presence check using prefix sum.
The nested loop checking for at least one 'X' in each submatrix runs in O((i+1) × (j+1)) time for each (i, j) pair, resulting in O(m² × n²) overall complexity. This can be optimized by maintaining a separate prefix sum matrix tracking X count.
Apply this diff to optimize the X-presence check:
prefix = [[0] * (n + 1) for _ in range(m + 1)]
+ x_count = [[0] * (n + 1) for _ in range(m + 1)]
for i in range(m):
for j in range(n):
val = 0
if grid[i][j] == 'X':
val = 1
elif grid[i][j] == 'Y':
val = -1
prefix[i + 1][j + 1] = val + prefix[i][j + 1] + prefix[i + 1][j] - prefix[i][j]
+ x_count[i + 1][j + 1] = (1 if grid[i][j] == 'X' else 0) + x_count[i][j + 1] + x_count[i + 1][j] - x_count[i][j]
res = 0
# Check all submatrices starting from (0,0)
for i in range(m):
for j in range(n):
- # Check if this submatrix contains at least one X
- has_x = False
- for x in range(i + 1):
- for y in range(j + 1):
- if grid[x][y] == 'X':
- has_x = True
- break
- if has_x:
- break
-
- if not has_x:
+ # Check if this submatrix contains at least one X using prefix sum
+ if x_count[i + 1][j + 1] == 0:
continueCommittable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In solutions/3212/01.py around lines 23 to 34, the code currently does an
O((i+1)*(j+1)) nested loop to detect any 'X' in the submatrix (0..i,0..j);
replace this with a prefix-sum approach: precompute an integer matrix xpref
where xpref[r][c] = number of 'X' in rectangle (0..r,0..c) (use standard
cumulative sum formula with boundary checks), then in the loop simply check if
xpref[i][j] == 0 and continue if so (or compute sum over any rectangle with
inclusion–exclusion if using different ranges); this changes the per-check
complexity to O(1) and removes the inner nested loops.
| class Solution: | ||
| def minimumCost(self, target: str, words: List[str], costs: List[int]) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing import for List.
The List type hint is used but not imported from the typing module, which will cause a NameError at runtime.
Apply this diff to add the required import:
+from typing import List
+
class Solution:
def minimumCost(self, target: str, words: List[str], costs: List[int]) -> int:📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| class Solution: | |
| def minimumCost(self, target: str, words: List[str], costs: List[int]) -> int: | |
| from typing import List | |
| class Solution: | |
| def minimumCost(self, target: str, words: List[str], costs: List[int]) -> int: |
🧰 Tools
🪛 Ruff (0.14.8)
2-2: Undefined name List
(F821)
2-2: Undefined name List
(F821)
🤖 Prompt for AI Agents
In solutions/3213/01.py around lines 1 to 2, the type hint List is used but not
imported; add the missing import by including from typing import List at the top
of the file so the type annotation resolves and avoids a NameError.
| class Solution: | ||
| def shortestDistanceAfterQueries( | ||
| self, n: int, queries: List[List[int]] | ||
| ) -> List[int]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing List import.
The type hint List[List[int]] requires importing List from the typing module; otherwise, this will raise a NameError at runtime.
Apply this diff to fix:
+from typing import List
+
+
class Solution:
def shortestDistanceAfterQueries(
self, n: int, queries: List[List[int]]
) -> List[int]:🧰 Tools
🪛 Ruff (0.14.8)
3-3: Undefined name List
(F821)
3-3: Undefined name List
(F821)
4-4: Undefined name List
(F821)
🤖 Prompt for AI Agents
In solutions/3244/01.py around lines 1-4, the function signature uses the type
name List but the module does not import List from typing; add "from typing
import List" at the top of the file (above the class definition) so the type
hints resolve correctly and avoid a NameError at runtime.
| class Solution: | ||
| def maxScore(self, grid: List[List[int]]) -> int: | ||
| from collections import defaultdict | ||
| from functools import lru_cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing List import.
The type hint List[List[int]] requires importing List from the typing module.
Apply this diff:
+from typing import List
+
+
class Solution:
def maxScore(self, grid: List[List[int]]) -> int:
from collections import defaultdict
from functools import lru_cache📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| class Solution: | |
| def maxScore(self, grid: List[List[int]]) -> int: | |
| from collections import defaultdict | |
| from functools import lru_cache | |
| from typing import List | |
| class Solution: | |
| def maxScore(self, grid: List[List[int]]) -> int: | |
| from collections import defaultdict | |
| from functools import lru_cache |
🧰 Tools
🪛 Ruff (0.14.8)
2-2: Undefined name List
(F821)
2-2: Undefined name List
(F821)
🤖 Prompt for AI Agents
In solutions/3276/01.py around lines 1 to 4, the type hint uses List[List[int]]
but List is not imported; add "from typing import List" (preferably at the top
of the file with other imports) so the annotation resolves correctly and
linters/type checkers won't error.
| class Solution: | ||
| def maximumProfit(self, prices: List[int], k: int) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing List import.
The type hint List[int] requires importing List from the typing module.
Apply this diff:
+from typing import List
+
+
class Solution:
def maximumProfit(self, prices: List[int], k: int) -> int:📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| class Solution: | |
| def maximumProfit(self, prices: List[int], k: int) -> int: | |
| from typing import List | |
| class Solution: | |
| def maximumProfit(self, prices: List[int], k: int) -> int: |
🧰 Tools
🪛 Ruff (0.14.8)
2-2: Undefined name List
(F821)
🤖 Prompt for AI Agents
In solutions/3573/01.py around lines 1 to 2, the function signature uses the
type hint List[int] but List is not imported; add "from typing import List" at
the top of the file (above the class definition) so the type hint resolves
correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on January 1
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| dp[i + word_len] = min(dp[i + word_len], dp[i] + costs[j]) | ||
|
|
||
| return dp[n] if dp[n] != float('inf') else -1 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Solution file included without explanation or PR mention
The solution file for problem 3213 appears to have been accidentally included. The PR title and description explicitly list problems 3178, 3179, 3212, 3244, 3276, and the Visualization list in book-sets.json adds 3573 as well. However, problem 3213 has a solution file but no corresponding explanation file in explanations/3213/en.md, is not mentioned anywhere in the PR description, and remains in the "All-TODO" list rather than being moved to the completed problems. This inconsistency suggests this file was unintentionally included in this commit.
Problems Solved
This PR adds solutions and explanations for 5 LeetCode problems:
Problem 3178: Find the Child Who Has the Ball After K Seconds
Problem 3179: Find the N-th Value After K Seconds
Problem 3212: Count Submatrices With Equal Frequency of X and Y
Problem 3244: Shortest Distance After Road Addition Queries II
Problem 3276: Select Cells in Grid With Maximum Score
Changes
solutions/<problem-number>/01.pyfor each problemexplanations/<problem-number>/en.mdfor each problemdata/book-sets.jsonto include problems in All-TODO listNote
This is part of a larger batch of 36 problems. The remaining problems will be processed in subsequent PRs.
Summary by Sourcery
Add solution and explanation for LeetCode problem 3573 with support for both normal and short-selling transactions using a transaction-bounded DP approach.
New Features:
Documentation:
Note
Adds solutions and explanations for seven LeetCode problems, updates book sets (incl. Visualization), and sets up Prettier + Husky pre-commit formatting.
solutions/for3178,3179,3212,3213,3244,3276,3573.explanations/for3178,3179,3212,3244,3276,3573.data/book-sets.json(prettified) and updates lists; expandsVisualizationset to include3178,3179,3212,3244,3276,3573.package.jsonscripts updated (format:json,prepare)..husky/pre-committo runnpm run format:json..gitignoreto ignorenode_modules/.Written by Cursor Bugbot for commit 8e3c0b7. This will update automatically on new commits. Configure here.
Summary by CodeRabbit
New Features
Documentation
Chores
Ignored Files
✏️ Tip: You can customize this high-level summary in your review settings.