LeetCode solutions

2334. Number of Flowers in Full Bloom

My accepted Python solution to LeetCode problem 2334, Number of Flowers in Full Bloom, running in 97ms.

  • Difficulty: Hard
  • Python
  • Runtime 97ms
  • Memory 40MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 97ms, memory 40MB, accepted 2026-01-02.

python
class Solution:
    def fullBloomFlowers(self, flowers: List[List[int]], people: List[int]) -> List[int]:
        from bisect import bisect_right, bisect_left
        
        starts = sorted(s for s, e in flowers)
        ends = sorted(e for s, e in flowers)
        
        result = []
        for p in people:
            # Count flowers that started <= p
            started = bisect_right(starts, p)
            # Count flowers that ended < p
            ended = bisect_left(ends, p)
            result.append(started - ended)
        
        return result

Source