Re: [閒聊] 每日leetcode

作者: Rushia (みけねこ的鼻屎)   2024-06-19 16:36:18
※ 引述《oin1104 (是oin的說)》之銘言:
: 1482. Minimum Number of Days to Make m Bouquets
: You are given an integer array bloomDay, an integer m and an integer k.
: You want to make m bouquets. To make a bouquet, you need to use k adjacent flowe
: rs from the garden.
: The garden consists of n flowers, the ith flower will bloom in the bloomDay[i] a
: nd then can be used in exactly one bouquet.
: Return the minimum number of days you need to wait to be able to make m bouquets
: from the garden. If it is impossible to make m bouquets return -1.
: Example 1:
: Input: bloomDay = [1,10,3,10,2], m = 3, k = 1
: Output: 3
: 題目 :
: 花園裡面有花
: 在他們的 bloomDay[i] 天開花
: 如果想要有m群 有k個相鄰的花 的花叢
: 那麼最少需要幾天
思路:
1.一樣偷看提示發現可以二分搜,我本來第一個corner case判斷是寫
m * k > bloomDay.length 結果第92個 case 給了一個超大的 m和k
導致溢位WA,結論就是恨py。
java code
作者: JIWP (JIWP)   2023-06-19 16:36:00
大師
作者: oin1104 (是oin的說)   2024-06-19 17:18:00
大師

Links booklink

Contact Us: admin [ a t ] ucptt.com