Skip to content

Conversation

@BrianLusina
Copy link
Owner

@BrianLusina BrianLusina commented Dec 25, 2025

Describe your change:

Flowers in full bloom on people's arrivals

  • 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 "Number of Flowers in Full Bloom" algorithm problem with multiple implementations
  • Documentation

    • Added README explaining the problem statement and solution approach using binary search techniques
  • Tests

    • Added comprehensive test coverage for the new algorithm implementations

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

@BrianLusina BrianLusina self-assigned this Dec 25, 2025
@BrianLusina BrianLusina added enhancement Algorithm Algorithm Problem Datastructures Datastructures Documentation Documentation Updates Array Array data structure Binary Search Binary Search Algorithm Intervals labels Dec 25, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 25, 2025

📝 Walkthrough

Walkthrough

The PR introduces a new problem solution "Number of Flowers in Full Bloom" with binary search–based implementations, adds an alternative merge-based approach to the count_days algorithm, and provides comprehensive documentation and test coverage for the new module.

Changes

Cohort / File(s) Summary
Documentation
DIRECTORY.md
Added new sub-entry for Full Bloom Flowers under Algorithms > Intervals, linking to test file.
Count Days Alternative
algorithms/intervals/count_days/__init__.py
Introduced count_days_2 implementation using merge-based overlap counting instead of incremental tracking; notes redundant sorts and duplicated initializations.
Full Bloom Flowers Module
algorithms/intervals/full_bloom_flowers/README.md, algorithms/intervals/full_bloom_flowers/__init__.py
New module with problem documentation and two function implementations (full_bloom_flowers, full_bloom_flowers_2) using sorted lists and binary search (bisect_right/bisect_left) to count flowers in bloom at each arrival time; O((n+m) log n) time complexity.
Full Bloom Tests
algorithms/intervals/full_bloom_flowers/test_full_bloom_flowers.py
New parameterized test suite validating both implementations against multiple flower configurations; note: contains duplicate test method names that may override at runtime.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

Sorting

Poem

🌸 In intervals where petals bloom and fall,
We sort and search through binary's call,
Two approaches bloom in algorithmic grace,
Racing to find each flower's place. 🐰

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding a full bloom flowers algorithm to the intervals directory, making it specific and appropriate.
Description check ✅ Passed The description follows the template with detailed change description and properly completed checklist items, though one non-critical item about issue resolution is unchecked.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/algorithms-intervals-full-bloom-flowers

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

Caution

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

⚠️ Outside diff range comments (1)
algorithms/intervals/count_days/__init__.py (1)

73-88: Remove duplicate code.

Lines 73–78 duplicate the logic that begins at line 80, including redundant sorts and variable initializations. This leftover code should be removed.

🔎 Proposed fix
-    # Sort the meetings based on their start time to process them in order
-    meetings.sort()
-
-    # Initialize a variable with 0 to count the number of days when the employee has meetings scheduled
-    occupied = 0
-
     # Initialize two variables with the first meeting's start and end times
     # Sort the meetings based on their start time to process them in order
     meetings.sort()
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d2e851 and 1c52afb.

📒 Files selected for processing (5)
  • DIRECTORY.md
  • algorithms/intervals/count_days/__init__.py
  • algorithms/intervals/full_bloom_flowers/README.md
  • algorithms/intervals/full_bloom_flowers/__init__.py
  • algorithms/intervals/full_bloom_flowers/test_full_bloom_flowers.py
🧰 Additional context used
🧬 Code graph analysis (1)
algorithms/intervals/full_bloom_flowers/test_full_bloom_flowers.py (1)
algorithms/intervals/full_bloom_flowers/__init__.py (2)
  • full_bloom_flowers (5-29)
  • full_bloom_flowers_2 (32-49)
🪛 markdownlint-cli2 (0.18.1)
DIRECTORY.md

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

(MD007, ul-indent)


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

(MD007, ul-indent)

🔇 Additional comments (3)
algorithms/intervals/full_bloom_flowers/README.md (1)

1-62: Excellent documentation!

The README provides a clear problem description, well-explained solution approach with step-by-step breakdown, and accurate complexity analysis. This will help future developers understand the algorithm.

algorithms/intervals/full_bloom_flowers/__init__.py (2)

5-29: LGTM!

The implementation correctly uses bisect_right to count flowers that started at or before the arrival time and bisect_left to count flowers that ended strictly before arrival. The logic is sound and well-documented.


32-49: LGTM!

The alternative implementation using end + 1 adjustment is clever and correct. By shifting the end boundary, both binary searches can consistently use bisect_right. The result matches the first implementation's behavior.

Comment on lines +27 to +31
def test_full_bloom_flowers(
self, flowers: List[List[int]], people: List[int], expected: List[int]
):
actual = full_bloom_flowers_2(flowers, people)
self.assertEqual(expected, actual)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Rename the duplicate test method.

The second test method has the same name as the first (line 20), which causes Python to override the first definition. This means full_bloom_flowers is never tested—only full_bloom_flowers_2 runs.

🔎 Proposed fix
     @parameterized.expand(TEST_CASES)
-    def test_full_bloom_flowers(
+    def test_full_bloom_flowers_2(
         self, flowers: List[List[int]], people: List[int], expected: List[int]
     ):
         actual = full_bloom_flowers_2(flowers, people)
         self.assertEqual(expected, actual)
📝 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.

Suggested change
def test_full_bloom_flowers(
self, flowers: List[List[int]], people: List[int], expected: List[int]
):
actual = full_bloom_flowers_2(flowers, people)
self.assertEqual(expected, actual)
def test_full_bloom_flowers_2(
self, flowers: List[List[int]], people: List[int], expected: List[int]
):
actual = full_bloom_flowers_2(flowers, people)
self.assertEqual(expected, actual)
🤖 Prompt for AI Agents
In algorithms/intervals/full_bloom_flowers/test_full_bloom_flowers.py around
lines 27 to 31 (and noting the duplicate at line 20), the second test method
reuses the same name as the first causing the first to be overridden; rename
this second test method to a unique name (for example test_full_bloom_flowers_2
or test_full_bloom_flowers_variant) so both implementations are executed, and
update any references or parametrization decorators accordingly to reflect the
new name.

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 Intervals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants