Number of Flowers in Full Bloom Problem

Number of Flowers in Full Bloom Problem — ExecCode Hard DSA Practice

Solve the Number of Flowers in Full Bloom problem on ExecCode. Free online hard DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Given flowers where flowers[i] = [starti, endi] describes when a flower blooms (inclusive), and query times people, return for each query time how many flowers are in full bloom, using an offline event-sweep built from difference-style boundary marks.

Examples

Input flowers = [[1, 6], [3, 7], [9, 12], [4, 13]], people = [2, 3, 11]; Output [1, 2, 2]. Input flowers = [[1, 10], [3, 3]], people = [3, 3, 3]; Output [2, 2, 2]. Input flowers = [[1, 4]], people = [5]; Output [0]

Constraints

1 ≤ flowers.length ≤ 5×10⁴ flowers[i].length == 2 1 ≤ starti ≤ endi ≤ 10⁹ 1 ≤ people.length ≤ 5×10⁴ 1 ≤ people[i] ≤ 10⁹

Practice Number of Flowers in Full Bloom free on ExecCode. Browse DSA problems, topic map, and placement guides.