Problem
Ask
Submissions

Problem: Number of Flowers in Full Bloom

hard
40 min
Explore how to apply modified binary search to solve interval problems like counting flowers in bloom at given times. Understand input arrays representing blooming intervals and arrival times, then implement efficient solutions to return the number of flowers in full bloom for each arrival.

Statement

You are given a 0-indexed 2D integer array, flowers, where each element flowers[i] =[starti,endi]= [start_i, end_i] represents the time interval during which the ithi^{th} flower is in full bloom (inclusive).

You are also given a 0-indexed integer array, people, of size nn, where people[i] denotes the time at which the ithi^{th} person arrives to view the flowers.

For each person, determine how many flowers are in full bloom at their arrival time. Return an integer array, ans, of length nn, where ans[i] is the number of blooming flowers when the ithi^{th} person arrives.

Constraints:

  • 1 \leq flowers.length \leq 10310^3

  • flowers[i].length ==2== 2

  • 1 \leq startistart_i \leq endiend_i \leq 10410^4

  • 1 \leq people.length \leq 10310^3

  • 1 \leq people[i] \leq 10410^4

Problem
Ask
Submissions

Problem: Number of Flowers in Full Bloom

hard
40 min
Explore how to apply modified binary search to solve interval problems like counting flowers in bloom at given times. Understand input arrays representing blooming intervals and arrival times, then implement efficient solutions to return the number of flowers in full bloom for each arrival.

Statement

You are given a 0-indexed 2D integer array, flowers, where each element flowers[i] =[starti,endi]= [start_i, end_i] represents the time interval during which the ithi^{th} flower is in full bloom (inclusive).

You are also given a 0-indexed integer array, people, of size nn, where people[i] denotes the time at which the ithi^{th} person arrives to view the flowers.

For each person, determine how many flowers are in full bloom at their arrival time. Return an integer array, ans, of length nn, where ans[i] is the number of blooming flowers when the ithi^{th} person arrives.

Constraints:

  • 1 \leq flowers.length \leq 10310^3

  • flowers[i].length ==2== 2

  • 1 \leq startistart_i \leq endiend_i \leq 10410^4

  • 1 \leq people.length \leq 10310^3

  • 1 \leq people[i] \leq 10410^4