bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 1482. Minimum Number of Days to Make m Bouquets

1482. Minimum Number of Days to Make m Bouquets

Leetcode Solutions

Binary Search Approach

  1. Initialize low to the minimum bloom day and high to the maximum bloom day.
  2. While low is less than or equal to high, do the following: a. Calculate mid as the average of low and high. b. Check if it's possible to make m bouquets by day mid. c. If it is possible, update high to mid - 1 (we will look for a smaller number of days). d. If it is not possible, update low to mid + 1 (we need more days).
  3. If we find a day where m bouquets can be made, return that day. Otherwise, return -1 if no such day exists.
UML Thumbnail

Linear Search Approach

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...