# Interview question from Baidu

• This question is a variant of k empty slot from leetcode. The new question is, how to find the last day when there are k consecutive boomed flowers.

e.g. total 7 days, 1 represents flower boomed，0 represents flower not boomed k=3

day1：1 0 0 0 0 0 0

day2：1 0 1 0 0 0 0

day3：1 1 1 0 0 0 0 1st time find k consecutive boomed flowersupdate: lastDayBoomKflowers = 3

day4：1 1 1 0 1 0 0

day5：1 1 1 0 1 1 0

day6：1 1 1 0 1 1 1 2nd time find k consecutive boomed flowersupdate: lastDayBoomKflowers = 6

day7：1 1 1 1 1 1 1

finally, flowers will boom at all position

so the final solution is lastDayBoomKflowers = 6

how can we get lastDayBoomKflowers? the time complexity is O(nlogn), space is O(n)

I know how to solve the original leetcode question, i would like to use tree set, but for this variation, I have no idea what data-structure I should use, and efficiently solve it.

Thank you for your time!

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.