Skip to content

Conversation

@BrianLusina
Copy link
Owner

@BrianLusina BrianLusina commented Jan 8, 2026

Describe your change:

  • Triangle Numbers
  • 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 Triangle Numbers, Trapping Rain Water, and Move Zeroes entries under Two Pointers; reorganized several array puzzles into Two Pointers.
  • Documentation

    • Expanded Three Sum writeup with solution details and diagrams; added/clarified READMEs and fixed image paths; minor formatting improvements in interval docs.
  • Tests

    • Introduced parameterized tests for multiple two-pointer problems, updated test imports, and removed legacy puzzle-level Move Zeroes tests.

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

@BrianLusina BrianLusina self-assigned this Jan 8, 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 labels Jan 8, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 8, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Reorganizes DIRECTORY moving multiple problems into a Two Pointers category, adds Triangle Numbers and Trapping Rain Water implementations/tests, relocates Move Zeroes and Two Sum artifacts into algorithms/two_pointers, refactors three_sum and move_zeroes implementations/tests, updates READMEs and image paths, and removes duplicate puzzle-level docs/tests.

Changes

Cohort / File(s) Summary
Triangle Numbers
algorithms/two_pointers/triangle_numbers/__init__.py, algorithms/two_pointers/triangle_numbers/README.md, algorithms/two_pointers/triangle_numbers/test_triangle_numbers.py
Added public function triangle_number(heights: List[int]) -> int (sort + two-pointers), README with explanation/examples, and parameterized unit tests.
Trapping Rain Water
algorithms/two_pointers/rain_water_trapped/__init__.py, algorithms/two_pointers/rain_water_trapped/README.md, algorithms/two_pointers/rain_water_trapped/test_trapped_rain_water.py, removed: puzzles/arrays/rain_water_trapped/__init__.py, puzzles/arrays/rain_water_trapped/README.md, puzzles/arrays/rain_water_trapped/test_trapped_rain_water.py
Added trapped_rain_water(heights: List[int]) -> int (two-pointer implementation), README and tests; removed previous puzzle-level module, docs, and tests.
Move Zeroes (relocated & tests)
algorithms/two_pointers/move_zeroes/__init__.py, algorithms/two_pointers/move_zeroes/README.md, algorithms/two_pointers/move_zeroes/test_move_zeroes.py, removed: puzzles/arrays/move_zeroes/README.md, puzzles/arrays/move_zeroes/test_move_zeroes.py
Reworked in-place algorithm to use next_non_zero index avoiding self-swaps; added README and parameterized tests under two_pointers; removed puzzle-level docs/tests.
Three Sum (refactor & tests)
algorithms/two_pointers/three_sum/__init__.py, algorithms/two_pointers/three_sum/README.md, algorithms/two_pointers/three_sum/test_three_sum.py
Replaced sum_ with total, added outer-loop duplicate skip and pointer duplicate-skipping after matches, advance both pointers on match; README expanded with solution walkthrough; tests consolidated to parameterized format.
Sort Colors (tests & API cleanup)
algorithms/two_pointers/sort_colors/__init__.py, algorithms/two_pointers/sort_colors/README.md, algorithms/two_pointers/sort_colors/test_sort_colors.py
Removed sort_colors_v2 public function; README expanded; tests unified to parameterized sort_colors tests and v2 references removed.
Two Sum & Two Sum Less K (docs/tests relocation)
algorithms/two_pointers/two_sum/test_two_sum.py, algorithms/two_pointers/two_sum/README.md, algorithms/two_pointers/two_sum_less_k/README.md
Updated test import paths to algorithms.two_pointers.two_sum; normalized image paths by removing leading ./ in READMEs.
Directory & small README edits
DIRECTORY.md, algorithms/intervals/insert_interval/README.md
DIRECTORY reorganized to reflect new Two Pointers entries; insert_interval README formatting updated to use inline code/backticks and minor phrasing edits.

Sequence Diagram(s)

(omitted — changes are algorithmic additions/refactors without multi-component interaction flows warranting a sequence diagram)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through arrays, pointers bright,
Counted triangles late at night,
Skipped duplicates, nudged zeros right,
Trapped rain in neat insight,
Docs and tests now tidy, light. ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is misleading and incomplete. It only mentions 'Triangle Numbers' but the PR makes substantial changes across multiple algorithms (Three Sum, Move Zeroes, Two Sum, Two Sum Less K) and reorganizes the directory structure. Update the description to accurately reflect all changes made: Triangle Numbers (new), Three Sum (refactored), Move Zeroes (reorganized), Two Sum variants (relocated), and DIRECTORY.md updates. Provide a comprehensive summary of modifications across multiple files.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(algorithms): two pointers' accurately reflects the main change—adding and refactoring two-pointer algorithms, including Triangle Numbers, Move Zeroes, Three Sum, and Two Sum reorganization.

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

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1d3baf and 6df7b66.

⛔ Files ignored due to path filters (23)
  • algorithms/two_pointers/rain_water_trapped/images/solutions/trapped_rain_water_solution_1.png is excluded by !**/*.png
  • algorithms/two_pointers/rain_water_trapped/images/solutions/trapped_rain_water_solution_10.png is excluded by !**/*.png
  • algorithms/two_pointers/rain_water_trapped/images/solutions/trapped_rain_water_solution_11.png is excluded by !**/*.png
  • algorithms/two_pointers/rain_water_trapped/images/solutions/trapped_rain_water_solution_2.png is excluded by !**/*.png
  • algorithms/two_pointers/rain_water_trapped/images/solutions/trapped_rain_water_solution_3.png is excluded by !**/*.png
  • algorithms/two_pointers/rain_water_trapped/images/solutions/trapped_rain_water_solution_4.png is excluded by !**/*.png
  • algorithms/two_pointers/rain_water_trapped/images/solutions/trapped_rain_water_solution_5.png is excluded by !**/*.png
  • algorithms/two_pointers/rain_water_trapped/images/solutions/trapped_rain_water_solution_6.png is excluded by !**/*.png
  • algorithms/two_pointers/rain_water_trapped/images/solutions/trapped_rain_water_solution_7.png is excluded by !**/*.png
  • algorithms/two_pointers/rain_water_trapped/images/solutions/trapped_rain_water_solution_8.png is excluded by !**/*.png
  • algorithms/two_pointers/rain_water_trapped/images/solutions/trapped_rain_water_solution_9.png is excluded by !**/*.png
  • algorithms/two_pointers/sort_colors/images/solutions/sort_colors_solution_1.png is excluded by !**/*.png
  • algorithms/two_pointers/sort_colors/images/solutions/sort_colors_solution_10.png is excluded by !**/*.png
  • algorithms/two_pointers/sort_colors/images/solutions/sort_colors_solution_11.png is excluded by !**/*.png
  • algorithms/two_pointers/sort_colors/images/solutions/sort_colors_solution_12.png is excluded by !**/*.png
  • algorithms/two_pointers/sort_colors/images/solutions/sort_colors_solution_2.png is excluded by !**/*.png
  • algorithms/two_pointers/sort_colors/images/solutions/sort_colors_solution_3.png is excluded by !**/*.png
  • algorithms/two_pointers/sort_colors/images/solutions/sort_colors_solution_4.png is excluded by !**/*.png
  • algorithms/two_pointers/sort_colors/images/solutions/sort_colors_solution_5.png is excluded by !**/*.png
  • algorithms/two_pointers/sort_colors/images/solutions/sort_colors_solution_6.png is excluded by !**/*.png
  • algorithms/two_pointers/sort_colors/images/solutions/sort_colors_solution_7.png is excluded by !**/*.png
  • algorithms/two_pointers/sort_colors/images/solutions/sort_colors_solution_8.png is excluded by !**/*.png
  • algorithms/two_pointers/sort_colors/images/solutions/sort_colors_solution_9.png is excluded by !**/*.png
📒 Files selected for processing (12)
  • DIRECTORY.md
  • algorithms/two_pointers/move_zeroes/README.md
  • algorithms/two_pointers/move_zeroes/test_move_zeroes.py
  • algorithms/two_pointers/rain_water_trapped/README.md
  • algorithms/two_pointers/rain_water_trapped/__init__.py
  • algorithms/two_pointers/rain_water_trapped/test_trapped_rain_water.py
  • algorithms/two_pointers/sort_colors/README.md
  • algorithms/two_pointers/sort_colors/__init__.py
  • algorithms/two_pointers/sort_colors/test_sort_colors.py
  • puzzles/arrays/rain_water_trapped/README.md
  • puzzles/arrays/rain_water_trapped/__init__.py
  • puzzles/arrays/rain_water_trapped/test_trapped_rain_water.py

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.

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/two_pointers/three_sum/__init__.py:
- Line 7: Fix the typo in the module docstring in three_sum's __init__.py:
change the word "Ww" to "We" so the sentence reads correctly (e.g., "We assume
that n is the length of the input array"); update the docstring text in
__init__.py accordingly.
🧹 Nitpick comments (4)
algorithms/two_pointers/three_sum/test_three_sum.py (1)

6-15: Remove duplicate test cases.

Lines 7 and 11 contain identical test cases, as do lines 10 and 14. These duplicates don't add value and should be removed.

♻️ Proposed refactor
 THREE_SUM_TEST_CASES = [
     ([-1, 0, 1, 2, -1, -4], [[-1, -1, 2], [-1, 0, 1]]),
     ([0, 1, 1], []),
     ([0, 0, 0], [[0, 0, 0]]),
     ([-1, 0, 1, 2, -1, -1], [[-1, -1, 2], [-1, 0, 1]]),
-    ([-1, 0, 1, 2, -1, -4], [[-1, -1, 2], [-1, 0, 1]]),
     ([-1, 0, 1, 2, -1, -4, 2], [[-1, -1, 2], [-1, 0, 1], [-4, 2, 2]]),
     ([-1, -1, 0, 1, 1, 1, 2], [[-1, -1, 2], [-1, 0, 1]]),
-    ([-1, 0, 1, 2, -1, -4, -1, 2, 1], [[-1, -1, 2], [-1, 0, 1], [-4, 2, 2]]),
 ]
DIRECTORY.md (1)

227-228: Consider adjusting indentation for consistency.

The indentation here (4 and 6 spaces) doesn't match the pattern used elsewhere in this file (2 and 4 spaces for nested lists). Consider adjusting for consistency.

♻️ Proposed fix
     * Three Sum
       * [Test Three Sum](https://github.com/BrianLusina/PythonSnips/blob/master/algorithms/two_pointers/three_sum/test_three_sum.py)
-    * Triangle Numbers
-      * [Test Triangle Numbers](https://github.com/BrianLusina/PythonSnips/blob/master/algorithms/two_pointers/triangle_numbers/test_triangle_numbers.py)
+  * Triangle Numbers
+    * [Test Triangle Numbers](https://github.com/BrianLusina/PythonSnips/blob/master/algorithms/two_pointers/triangle_numbers/test_triangle_numbers.py)
algorithms/two_pointers/triangle_numbers/test_triangle_numbers.py (1)

6-10: Consider adding test case for empty input.

The triangle_number implementation handles empty input with an early return, but there's no test case to verify this behavior.

🧪 Proposed addition
 TRIANGLE_NUMBER_TEST_CASES = [
+    ([], 0),
     ([11, 4, 9, 6, 15, 18], 10),
     ([2,2,3,4], 3),
     ([4,2,3,4], 4),
 ]
algorithms/two_pointers/triangle_numbers/__init__.py (1)

26-48: Algorithm implementation is correct.

The two-pointer approach correctly identifies valid triangles using the triangle inequality. The counting logic count += right - left is elegant and correct for a sorted array.

The comments on lines 44 and 47 could be clarified for better readability:

📝 Suggested comment improvements
-                # we decrement right to check if there are valid triplets that can be formed by decreasing the middle valid
+                # Decrement right to check for more valid triplets with a smaller second side
                 right -= 1
             else:
-                # Increase the left to find the next maximum minimum number that can form a valid triplet
+                # Increment left to find a larger first side that can form a valid triplet
                 left += 1
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c30b66 and b5bf32f.

⛔ Files ignored due to path filters (47)
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_1.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_10.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_11.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_12.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_13.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_14.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_15.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_16.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_17.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_18.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_19.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_2.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_3.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_4.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_5.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_6.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_7.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_8.png is excluded by !**/*.png
  • algorithms/two_pointers/three_sum/images/solutions/three_sum_solution_9.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_1.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_10.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_11.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_12.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_13.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_14.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_15.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_16.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_17.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_18.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_19.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_2.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_20.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_21.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_22.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_23.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_24.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_25.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_26.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_27.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_28.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_3.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_4.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_5.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_6.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_7.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_8.png is excluded by !**/*.png
  • algorithms/two_pointers/triangle_numbers/images/solutions/triangle_numbers_solution_9.png is excluded by !**/*.png
📒 Files selected for processing (8)
  • DIRECTORY.md
  • algorithms/intervals/insert_interval/README.md
  • algorithms/two_pointers/three_sum/README.md
  • algorithms/two_pointers/three_sum/__init__.py
  • algorithms/two_pointers/three_sum/test_three_sum.py
  • algorithms/two_pointers/triangle_numbers/README.md
  • algorithms/two_pointers/triangle_numbers/__init__.py
  • algorithms/two_pointers/triangle_numbers/test_triangle_numbers.py
🧰 Additional context used
🧬 Code graph analysis (1)
algorithms/two_pointers/triangle_numbers/test_triangle_numbers.py (1)
algorithms/two_pointers/triangle_numbers/__init__.py (1)
  • triangle_number (4-51)
🪛 LanguageTool
algorithms/two_pointers/triangle_numbers/README.md

[style] ~64-~64: Using many exclamation marks might seem excessive (in this case: 20 exclamation marks for a text that’s 3306 characters long)
Context: ...utions/triangle_numbers_solution_9.png) Solution 10 Solution 11 Solution 12 Solution 13 Solution 14 Solution 15 Solution 16 Solution 17 Solution 18 Solution 19 Solution 20 Solution 21 Solution 22 Solution 23 Solution 24 Solution 25 Solution 26 ![Solution 27](./images/solutions/triangl...

(EN_EXCESSIVE_EXCLAMATION)

algorithms/two_pointers/three_sum/README.md

[style] ~82-~82: Using many exclamation marks might seem excessive (in this case: 9 exclamation marks for a text that’s 2415 characters long)
Context: ...es/solutions/three_sum_solution_15.png) ![Solution 16](./images/solutions/three_s...

(EN_EXCESSIVE_EXCLAMATION)

🪛 markdownlint-cli2 (0.18.1)
DIRECTORY.md

227-227: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


228-228: Unordered list indentation
Expected: 4; Actual: 6

(MD007, ul-indent)

🔇 Additional comments (8)
algorithms/intervals/insert_interval/README.md (1)

28-28: Documentation formatting looks good.

The addition of backticks around variable names and code references (merged, newInterval, intervals) improves readability and aligns with markdown documentation conventions. The phase descriptions are clear and accurately describe the algorithm's logic.

Also applies to: 31-48

algorithms/two_pointers/three_sum/__init__.py (1)

42-49: LGTM! Effective duplicate handling.

The duplicate skipping logic correctly prevents duplicate triplets by advancing both pointers past equal values after finding a valid triplet. This ensures all unique triplets are captured exactly once.

algorithms/two_pointers/triangle_numbers/__init__.py (5)

4-14: LGTM! Well-documented function signature.

The function signature with type hints and the comprehensive docstring clearly explain the purpose and behavior. The warning about in-place manipulation is particularly valuable for callers.


16-17: LGTM! Proper edge case handling.

The early return for empty or falsy input is correct and prevents unnecessary computation.


19-21: LGTM! Sorting is correctly applied.

The in-place sort prepares the array for the two-pointer technique, and the complexity analysis is accurate.


50-51: LGTM! Clean return statement.

The final return is straightforward and properly documented.


4-51: In-place modification is properly documented and handled.

The function's docstring clearly states that input is manipulated in-place, and the only visible caller (the test suite) correctly handles this by not relying on the original list state after the function returns. No changes needed.

algorithms/two_pointers/three_sum/README.md (1)

36-92: LGTM! Clear and comprehensive documentation.

The Solution section provides an excellent walkthrough of the two-pointer approach for the Three Sum problem. The explanation logically progresses from the basic algorithm to handling duplicates and termination conditions. All 19 referenced solution images are present in the ./images/solutions/ directory.

BrianLusina and others added 3 commits January 8, 2026 14:07
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
algorithms/two_pointers/move_zeroes/__init__.py (1)

4-27: Update docstring to match refactored implementation.

The function's docstring (lines 7-10) describes a "left & right pointers" approach, but the current implementation uses a single next_non_zero pointer with an index-based loop. While the algorithm is correct and efficient, the documentation should accurately describe the implementation.

📝 Suggested docstring update
 def move_zeroes(nums: List[int]) -> None:
     """
     Modifies the list in place by moving the non-zero elements to the front maintaining their order and the zero elements
-    to the back. This uses 2 pointers with the left & right pointers being initialized at 0 and checking the value of
-    each pointer at each iteration. It performs a swap of the values if the left and right pointers are at elements
-    that are 0 and non-zero respectively, This way, non-zero elements retain their order, while 0 elements are moved to
-    the back.
+    to the back. This uses a single pointer (next_non_zero) to track the position where the next non-zero element should
+    be placed. As we iterate through the list, when a non-zero element is found, it's swapped with the position at
+    next_non_zero (if different), then next_non_zero is incremented. This way, non-zero elements retain their order
+    while zero elements are moved to the back.
 
     Complexity:
🤖 Fix all issues with AI agents
In @algorithms/two_pointers/move_zeroes/README.md:
- Line 42: The README contains a duplicate image reference: the img tag at the
second occurrence uses move_zeroes_solution_1.png but should point to the
distinct file move_zeroes_solution_11.png; update the image reference in
algorithms/two_pointers/move_zeroes/README.md to use move_zeroes_solution_11.png
so the displayed image matches the intended Solution 11.

In @algorithms/two_pointers/move_zeroes/test_move_zeroes.py:
- Line 20: The test function signature for test_move_zeroes has an invalid type
hint for the expected parameter; update the signature in test_move_zeroes to use
a proper typing annotation (expected: List[int]) to match nums and follow Python
typing conventions, ensuring any necessary imports (List) are present at the top
of the test file.
🧹 Nitpick comments (1)
algorithms/two_pointers/move_zeroes/README.md (1)

32-42: Consider consistent image path format.

These image paths use ./images/... format, while the Two Sum README was updated to use images/... (without the leading ./). For consistency across the two_pointers documentation, consider using the same format.

♻️ Optional consistency improvement
-![Solution 1](./images/solutions/move_zeroes_solution_1.png)
-![Solution 2](./images/solutions/move_zeroes_solution_2.png)
+![Solution 1](images/solutions/move_zeroes_solution_1.png)
+![Solution 2](images/solutions/move_zeroes_solution_2.png)

(Apply similar changes to all image references in lines 32-44)

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b5bf32f and b1d3baf.

⛔ Files ignored due to path filters (34)
  • algorithms/two_pointers/move_zeroes/images/solutions/move_zeroes_solution_1.png is excluded by !**/*.png
  • algorithms/two_pointers/move_zeroes/images/solutions/move_zeroes_solution_10.png is excluded by !**/*.png
  • algorithms/two_pointers/move_zeroes/images/solutions/move_zeroes_solution_11.png is excluded by !**/*.png
  • algorithms/two_pointers/move_zeroes/images/solutions/move_zeroes_solution_12.png is excluded by !**/*.png
  • algorithms/two_pointers/move_zeroes/images/solutions/move_zeroes_solution_13.png is excluded by !**/*.png
  • algorithms/two_pointers/move_zeroes/images/solutions/move_zeroes_solution_2.png is excluded by !**/*.png
  • algorithms/two_pointers/move_zeroes/images/solutions/move_zeroes_solution_3.png is excluded by !**/*.png
  • algorithms/two_pointers/move_zeroes/images/solutions/move_zeroes_solution_4.png is excluded by !**/*.png
  • algorithms/two_pointers/move_zeroes/images/solutions/move_zeroes_solution_5.png is excluded by !**/*.png
  • algorithms/two_pointers/move_zeroes/images/solutions/move_zeroes_solution_6.png is excluded by !**/*.png
  • algorithms/two_pointers/move_zeroes/images/solutions/move_zeroes_solution_7.png is excluded by !**/*.png
  • algorithms/two_pointers/move_zeroes/images/solutions/move_zeroes_solution_8.png is excluded by !**/*.png
  • algorithms/two_pointers/move_zeroes/images/solutions/move_zeroes_solution_9.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum/images/examples/two_sum_4_input_is_bst_example_1.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum/images/examples/two_sum_4_input_is_bst_example_2.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum/images/examples/two_sum_4_input_is_bst_example_3.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum/images/solutions/two_sum_4_input_is_bst_solution_1.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum/images/solutions/two_sum_4_input_is_bst_solution_10.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum/images/solutions/two_sum_4_input_is_bst_solution_11.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum/images/solutions/two_sum_4_input_is_bst_solution_12.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum/images/solutions/two_sum_4_input_is_bst_solution_13.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum/images/solutions/two_sum_4_input_is_bst_solution_14.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum/images/solutions/two_sum_4_input_is_bst_solution_2.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum/images/solutions/two_sum_4_input_is_bst_solution_3.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum/images/solutions/two_sum_4_input_is_bst_solution_4.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum/images/solutions/two_sum_4_input_is_bst_solution_5.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum/images/solutions/two_sum_4_input_is_bst_solution_6.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum/images/solutions/two_sum_4_input_is_bst_solution_7.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum/images/solutions/two_sum_4_input_is_bst_solution_8.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum/images/solutions/two_sum_4_input_is_bst_solution_9.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum_less_k/images/examples/two_sum_less_k_example_1.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum_less_k/images/examples/two_sum_less_k_example_2.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum_less_k/images/examples/two_sum_less_k_example_3.png is excluded by !**/*.png
  • algorithms/two_pointers/two_sum_less_k/images/examples/two_sum_less_k_example_4.png is excluded by !**/*.png
📒 Files selected for processing (17)
  • DIRECTORY.md
  • algorithms/two_pointers/array_3_pointers/README.md
  • algorithms/two_pointers/array_3_pointers/__init__.py
  • algorithms/two_pointers/array_3_pointers/test_array_3_pointers.py
  • algorithms/two_pointers/move_zeroes/README.md
  • algorithms/two_pointers/move_zeroes/__init__.py
  • algorithms/two_pointers/move_zeroes/test_move_zeroes.py
  • algorithms/two_pointers/three_sum/__init__.py
  • algorithms/two_pointers/triangle_numbers/test_triangle_numbers.py
  • algorithms/two_pointers/two_sum/README.md
  • algorithms/two_pointers/two_sum/__init__.py
  • algorithms/two_pointers/two_sum/test_two_sum.py
  • algorithms/two_pointers/two_sum_less_k/README.md
  • algorithms/two_pointers/two_sum_less_k/__init__.py
  • algorithms/two_pointers/two_sum_less_k/test_two_sum.py
  • puzzles/arrays/move_zeroes/README.md
  • puzzles/arrays/move_zeroes/test_move_zeroes.py
💤 Files with no reviewable changes (2)
  • puzzles/arrays/move_zeroes/README.md
  • puzzles/arrays/move_zeroes/test_move_zeroes.py
✅ Files skipped from review due to trivial changes (1)
  • algorithms/two_pointers/two_sum_less_k/README.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • algorithms/two_pointers/triangle_numbers/test_triangle_numbers.py
  • algorithms/two_pointers/three_sum/init.py
🧰 Additional context used
🧬 Code graph analysis (2)
algorithms/two_pointers/move_zeroes/test_move_zeroes.py (1)
algorithms/two_pointers/move_zeroes/__init__.py (2)
  • move_zeroes (4-27)
  • move_zeroes_one (30-65)
algorithms/two_pointers/two_sum/test_two_sum.py (1)
algorithms/two_pointers/two_sum/__init__.py (1)
  • two_sum (6-32)
🪛 LanguageTool
algorithms/two_pointers/two_sum/README.md

[style] ~81-~81: Using many exclamation marks might seem excessive (in this case: 13 exclamation marks for a text that’s 3525 characters long)
Context: .../two_sum_4_input_is_bst_solution_1.png) Solution 2 Solution 3 Solution 4 Solution 5 Solution 6 Solution 7 Solution 8 Solution 9 Solution 10 Solution 11 Solution 12 ![Solution 13](images/solutions/two_sum_4...

(EN_EXCESSIVE_EXCLAMATION)

algorithms/two_pointers/move_zeroes/README.md

[style] ~32-~32: Using many exclamation marks might seem excessive (in this case: 11 exclamation marks for a text that’s 1346 characters long)
Context: ...s/solutions/move_zeroes_solution_1.png) Solution 2 Solution 3 Solution 4 Solution 5 Solution 6 Solution 7 Solution 8 Solution 9 Solution 10 Solution 11 ![Solution 12](./images/solutions/move_ze...

(EN_EXCESSIVE_EXCLAMATION)

🪛 markdownlint-cli2 (0.18.1)
DIRECTORY.md

209-209: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


210-210: Unordered list indentation
Expected: 4; Actual: 6

(MD007, ul-indent)


211-211: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


212-212: Unordered list indentation
Expected: 4; Actual: 6

(MD007, ul-indent)


213-213: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


214-214: Unordered list indentation
Expected: 4; Actual: 6

(MD007, ul-indent)


215-215: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


216-216: Unordered list indentation
Expected: 4; Actual: 6

(MD007, ul-indent)


227-227: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


228-228: Unordered list indentation
Expected: 4; Actual: 6

(MD007, ul-indent)


229-229: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


230-230: Unordered list indentation
Expected: 4; Actual: 6

(MD007, ul-indent)


231-231: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


232-232: Unordered list indentation
Expected: 4; Actual: 6

(MD007, ul-indent)

🔇 Additional comments (7)
algorithms/two_pointers/two_sum/README.md (1)

54-94: LGTM! Image path consistency improvement.

The removal of the leading ./ from image paths improves consistency across the documentation. The paths remain valid and functional.

DIRECTORY.md (1)

209-232: Added Two Pointers algorithm entries successfully.

The new entries for Array 3 Pointers, Move Zeroes, Triangle Numbers, Two Sum, and Two Sum Less K are correctly formatted and linked. The indentation style matches the existing format used throughout this file.

Note: The markdownlint warnings about indentation (MD007) apply to the existing file style, not just these changes. If you wish to address these warnings, consider a separate formatting PR to update the entire file consistently.

algorithms/two_pointers/move_zeroes/__init__.py (1)

22-27: LGTM! Efficient refactoring with self-swap optimization.

The refactored implementation correctly moves zeros to the end while maintaining the relative order of non-zero elements. The conditional check if idx != next_non_zero: is a good optimization that prevents unnecessary self-swaps when no zeros have been encountered yet.

algorithms/two_pointers/two_sum/test_two_sum.py (1)

5-9: Import path update verified successfully.

The import path change from algorithms.arrays.two_sum to algorithms.two_pointers.two_sum is complete across the codebase. No remaining references to the old path exist, and the new module location is properly established.

algorithms/two_pointers/move_zeroes/test_move_zeroes.py (3)

1-4: LGTM! Imports are clean and appropriate.

The imports are well-organized and include all necessary dependencies for parameterized testing and type hints.


6-15: Good test coverage with diverse scenarios.

The test cases comprehensively cover various edge cases including single elements, all zeros, no zeros, and mixed positions. This ensures both implementations handle the full range of inputs correctly.


30-31: LGTM! Standard unittest runner.

The main block follows the standard unittest convention for running tests directly.

@github-actions
Copy link

github-actions bot commented Jan 8, 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 6df7b66

BrianLusina and others added 4 commits January 8, 2026 15:16
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@BrianLusina BrianLusina merged commit 629a536 into main Jan 8, 2026
4 of 6 checks passed
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 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