Skip to content

Conversation

@BrianLusina
Copy link
Owner

@BrianLusina BrianLusina commented Jan 19, 2026

Describe your change:

Adds the following algorithms:

  • Count number of distinct pairs of numbers whose sum is strictly less than target
  • Split Array largest Sum
  • Decode ways

Modified some test cases as well

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

Summary by CodeRabbit

  • New Features

    • Added three algorithm problems: Decode Ways (Dynamic Programming), Split Array Largest Sum (Binary Search), and Count Pairs (Two Pointers).
  • Documentation

    • Added full problem guides with examples, solutions, constraints, and complexity analysis for each problem.
  • Tests

    • Added extensive parameterized test suites covering edge cases and typical scenarios for all new problems.
  • Refactor

    • Minor test/import formatting and internal helper restructuring to improve readability.
  • Chores

    • Updated navigation index to include the new problem entries.

✏️ Tip: You can customize this high-level summary in your review settings.

@BrianLusina BrianLusina self-assigned this Jan 19, 2026
@BrianLusina BrianLusina added enhancement Algorithm Algorithm Problem Datastructures Datastructures Documentation Documentation Updates Sorting Contains sorting in the algorithm Array Array data structure Two Pointers Two pointer algorithm Binary Search Binary Search Algorithm labels Jan 19, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

Warning

Rate limit exceeded

@BrianLusina has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 31 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 68db8ae and c1903b0.

📒 Files selected for processing (1)
  • algorithms/search/binary_search/split_array_largest_sum/README.md
📝 Walkthrough

Walkthrough

Adds three algorithm problem implementations (Decode Ways, Split Array Largest Sum, Count Pairs) with READMEs and tests, refactors an internal helper in two_sum_less_k and parameterizes related tests, tweaks one test import formatting, and updates DIRECTORY.md navigation entries.

Changes

Cohort / File(s) Summary
Decode Ways - Dynamic Programming
algorithms/dynamic_programming/decodeways/README.md, algorithms/dynamic_programming/decodeways/__init__.py, algorithms/dynamic_programming/decodeways/test_num_decodings.py
Adds README, implements num_decodings(s: str) -> int with DP, and adds parameterized tests covering leading zeros and edge cases.
Split Array Largest Sum - Binary Search
algorithms/search/binary_search/split_array_largest_sum/README.md, algorithms/search/binary_search/split_array_largest_sum/__init__.py, algorithms/search/binary_search/split_array_largest_sum/test_split_array_largest_sum.py
Adds README, two binary-search implementations (split_array, split_array_2) for minimizing largest subarray sum, and a large comprehensive test suite.
Count Pairs - Two Pointers
algorithms/two_pointers/count_pairs/README.md, algorithms/two_pointers/count_pairs/__init__.py, algorithms/two_pointers/count_pairs/test_count_pairs.py
Adds README and count_pairs(nums: List[int], target: int) -> int using sort + two-pointer approach, with parameterized tests.
Two Sum Less K - Refactor & Tests
algorithms/two_pointers/two_sum_less_k/__init__.py, algorithms/two_pointers/two_sum_less_k/test_two_sum.py
Moves binary-search search() helper to be nested inside two_sum_less_than_k, adjusts docstring annotation; test file converted to parameterized data-driven tests.
Paint House Test Formatting
algorithms/dynamic_programming/painthouse/test_min_cost_to_paint_houses.py
Minor formatting changes to imports and __name__ check only.
Navigation Index
DIRECTORY.md
Inserts entries linking the new test files: Test Num Decodings, Test Split Array Largest Sum, Test Count Pairs.

Sequence Diagram(s)

(omitted — changes are algorithmic additions and small refactors without multi-component sequential flows requiring diagramming)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

Dynamic Programming

Poem

🐰 I hopped through code with eager paws,
New decodings, splits, and paired-sum laws,
I nested a helper, tidied a test,
More algorithms now greet each quest,
Happy hops — more puzzles to applause! 🎩

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description lists the three algorithms added and notes test modifications, but contradicts the checklist claim of 'only changes one algorithm file' when multiple algorithm files were modified. Clarify whether the PR violates the single-file change policy or if the checklist was incorrectly marked. The PR appears to modify multiple algorithm files (count_pairs, split_array_largest_sum, decode_ways) plus supporting infrastructure, contradicting the stated checklist item.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: addition of two-pointers and dynamic programming/binary search algorithms.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Jan 19, 2026

Warnings
⚠️ ❗ Big PR

: Pull Request size seems relatively large. If Pull Request contains multiple changes, split each into separate PR will helps faster, easier review.

Generated by 🚫 dangerJS against c1903b0

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Fix all issues with AI agents
In `@algorithms/search/binary_search/split_array_largest_sum/__init__.py`:
- Around line 42-46: split_array_2 currently calls max(nums)/sum(nums) without
handling empty input; add the same empty-input guard used in split_array (check
for an empty nums at the top of split_array_2 before computing left/right) and
return the identical value that split_array returns for empty input so behavior
is consistent; insert this guard immediately before the lines that compute left,
right to prevent ValueError from max()/sum().

In `@algorithms/search/binary_search/split_array_largest_sum/README.md`:
- Line 1: The Markdown heading in README.md has incorrect spacing ("#  Split
Array Largest Sum"); update the heading in the file so there is exactly one
space after the hash (e.g., "# Split Array Largest Sum") to satisfy MD019 and
correct the heading formatting.
- Around line 104-106: In the README under the "Space Complexity" heading
replace the incorrect phrase "The time complexity of this solution is O(1)
because only constant space is used." with a correctly worded sentence
referencing space (e.g., "The space complexity of this solution is O(1) because
only constant space is used.") so the label and description match; update the
"Space Complexity" section text accordingly.

In `@algorithms/two_pointers/count_pairs/README.md`:
- Around line 32-35: Update the wording in the README to consistently hyphenate
"two-pointer" wherever the phrase appears (e.g., change "two pointers" and "two
pointer approach" to "two-pointer" and "two-pointer approach") so the style is
uniform across the paragraph describing sorting and pointer initialization.

In `@DIRECTORY.md`:
- Around line 62-63: Indentation of the nested list entries under "Decodeways"
is incorrect for markdownlint MD007; locate the "Decodeways" heading and the
linked list item "[Test Num
Decodings](https://github.com/BrianLusina/PythonSnips/blob/master/algorithms/dynamic_programming/decodeways/test_num_decodings.py)"
and change their indentation to the expected 2-space nesting (align the bullet
and its child links with two spaces per nesting level) and apply the same fix to
the other occurrences mentioned (around the entries at the other reported
locations).
🧹 Nitpick comments (2)
algorithms/search/binary_search/split_array_largest_sum/test_split_array_largest_sum.py (1)

9-15: Drop duplicated test cases to reduce noise.
These entries repeat and don’t add coverage.

♻️ Suggested cleanup
 SPLIT_ARRAY_LARGEST_SUM_TEST_CASES = [
     ([1, 2, 3, 4, 5], 3, 6),
     ([1, 2, 3, 4, 5], 2, 9),
     ([5, 8, 2, 8, 3, 1], 1, 27),
-    ([1, 2, 3, 4, 5], 3, 6),
-    ([5, 8, 2, 8, 3, 1], 1, 27),
     ([3, 4, 5, 4, 2], 4, 6),
algorithms/dynamic_programming/decodeways/test_num_decodings.py (1)

5-17: Remove duplicate test case; consider adding empty-string coverage.

Line 7 and Line 11 repeat ("12", 2), which is redundant. You could replace the duplicate with an empty-string case to cover the not s branch.

♻️ Suggested tweak
 NUM_DECODINGS_TEST_CASES = [
     ("11106", 2),
     ("12", 2),
     ("226", 3),
     ("06", 0),
     ("101", 1),
-    ("12", 2),
+    ("", 0),
     ("012", 0),
     ("0", 0),
     ("30", 0),
     ("10", 1),
     ("27", 1),
 ]

BrianLusina and others added 3 commits January 19, 2026 10:04
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@github-actions github-actions bot force-pushed the feat/algorithms-dp-bs branch from 44f0e0b to 68db8ae Compare January 19, 2026 07:05
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@algorithms/search/binary_search/split_array_largest_sum/README.md`:
- Line 100: Fix the missing space in the inline code phrase by changing
"`max(nums)`to `sum(nums)`" to "`max(nums)` to `sum(nums)`" in the README text
so there's a space between the closing backtick of `max(nums)` and the word
"to".

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@BrianLusina BrianLusina merged commit 736636e into main Jan 19, 2026
5 of 7 checks passed
@BrianLusina BrianLusina deleted the feat/algorithms-dp-bs branch January 19, 2026 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Algorithm Algorithm Problem Array Array data structure Binary Search Binary Search Algorithm Datastructures Datastructures Documentation Documentation Updates enhancement Sorting Contains sorting in the algorithm Two Pointers Two pointer algorithm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants