Skip to content

feat(algorithms, heap): trapping rain water ii - #203

Merged
BrianLusina merged 4 commits into
mainfrom
feat/algorithms/trap-rain-water-ii
Aug 15, 2026
Merged

feat(algorithms, heap): trapping rain water ii#203
BrianLusina merged 4 commits into
mainfrom
feat/algorithms/trap-rain-water-ii

Conversation

@BrianLusina

@BrianLusina BrianLusina commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Describe your change:

Adds an algorithm to solve for finding how much rain water is trapped in a 3D container(grid) with varying heights per cell.

  • 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 support for calculating trapped rainwater across 2D height maps.
    • Added the Trapping Rain Water II problem to the algorithm directory.
    • Updated the directory index with additional algorithm entries.
  • Documentation

    • Added problem details, examples, constraints, and related topics for the new algorithm.
  • Tests

    • Added coverage for multiple height-map scenarios and expected water totals.

BrianLusina and others added 2 commits August 15, 2026 09:39
Adds an algorithm that solves the challenge of trapping rain water
in a 3D space using a heap
@BrianLusina BrianLusina self-assigned this Aug 15, 2026
@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@BrianLusina, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 32 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: df5f144a-68b8-4031-9b98-1911b1380a40

📥 Commits

Reviewing files that changed from the base of the PR and between df8ba80 and 7b1c301.

📒 Files selected for processing (12)
  • .github/workflows/directory_writer.yml
  • .github/workflows/lint.yml
  • .github/workflows/pre-commit.yml
  • Makefile
  • datastructures/linked_lists/linked_list_utils.py
  • datastructures/linked_lists/node.py
  • datastructures/linked_lists/singly_linked_list/single_linked_list.py
  • datastructures/sparse_vector/test_sparse_vector.py
  • datastructures/trees/binary/tree/test_binary_tree_invert_tree.py
  • datastructures/trees/heaps/binary/min_heap/min_array_heap.py
  • design_patterns/event_stream/processor.py
  • pyproject.toml

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a9b749b-8fc4-4eee-bb61-06e02c814b0a

📥 Commits

Reviewing files that changed from the base of the PR and between 8a5f81d and df8ba80.

⛔ Files ignored due to path filters (2)
  • algorithms/heap/trapping_rain_water_ii/images/examples/trapping_rain_water_ii_example_1.png is excluded by !**/*.png
  • algorithms/heap/trapping_rain_water_ii/images/examples/trapping_rain_water_ii_example_2.png is excluded by !**/*.png
📒 Files selected for processing (4)
  • DIRECTORY.md
  • algorithms/heap/trapping_rain_water_ii/README.md
  • algorithms/heap/trapping_rain_water_ii/__init__.py
  • algorithms/heap/trapping_rain_water_ii/test_trapping_rain_water_ii.py

📝 Walkthrough

Walkthrough

The pull request adds Trapping Rain Water II with two min-heap implementations, documentation, and tests. It also updates DIRECTORY.md with links for several algorithm and design-pattern entries.

Changes

Trapping Rain Water II

Layer / File(s) Summary
Problem contract and heap cell model
algorithms/heap/trapping_rain_water_ii/README.md, algorithms/heap/trapping_rain_water_ii/__init__.py
The package documents the problem and adds the public Cell class for height-ordered heap processing.
Boundary traversal and validation
algorithms/heap/trapping_rain_water_ii/__init__.py, algorithms/heap/trapping_rain_water_ii/test_trapping_rain_water_ii.py, DIRECTORY.md
trap_rain_water and trap_rain_water_2 process boundary cells and accumulate trapped water. Parameterised tests cover two height maps. The directory index links the new algorithm.

Directory index updates

Layer / File(s) Summary
Directory catalogue links
DIRECTORY.md
The index adds links for Kth Smallest in Lexicographic Order, All O One files, and My Pow.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to df8ba

This PR adds a localized trapping-rain-water algorithm and related documentation and tests; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant trap_rain_water_2
  participant min_heap
  participant height_map
  trap_rain_water_2->>height_map: read boundary cells
  trap_rain_water_2->>min_heap: enqueue boundary Cell objects
  trap_rain_water_2->>min_heap: pop lowest effective height
  trap_rain_water_2->>height_map: inspect unvisited neighbours
  trap_rain_water_2->>min_heap: enqueue neighbours with effective heights
Loading

Poem

I’m a rabbit beside the heap,
Counting water cells in tidy rows.
Boundary heights go in first,
Then trapped blue water grows.
Tests thump softly: all results pass.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description follows the required template, explains the algorithm and documentation changes, and completes the relevant checklist items.
Title check ✅ Passed The title clearly identifies the new Trapping Rain Water II algorithm and its algorithmic area.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/algorithms/trap-rain-water-ii

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.

@BrianLusina
BrianLusina merged commit be0b302 into main Aug 15, 2026
9 checks passed
@BrianLusina
BrianLusina deleted the feat/algorithms/trap-rain-water-ii branch August 15, 2026 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant