File tree 1 file changed +3
-35
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +3
-35
lines changed Original file line number Diff line number Diff line change 1
1
package com .fishercoder .solutions ;
2
2
3
- /**
4
- * 683. K Empty Slots
5
- *
6
- * There is a garden with N slots. In each slot, there is a flower.
7
- *
8
- * The N flowers will bloom one by one in N days.
9
- *
10
- * In each day, there will be exactly one flower blooming and it will be in the status of blooming since then.
11
- *
12
- * Given an array flowers consists of number from 1 to N. Each number in the array represents the place where the flower will open in that day.
13
- * For example, flowers[i] = x means that the unique flower that blooms at day i will be at position x,
14
- * where i and x will be in the range from 1 to N.
15
- *
16
- * Also given an integer k, you need to output in which day there exists two flowers in the status of blooming,
17
- * and also the number of flowers between them is k and these flowers are not blooming.
18
- * If there isn't such day, output -1.
19
-
20
- Example 1:
21
- Input:
22
- flowers: [1,3,2]
23
- k: 1
24
- Output: 2
25
- Explanation: In the second day, the first and the third flower have become blooming.
26
-
27
- Example 2:
28
- Input:
29
- flowers: [1,2,3]
30
- k: 1
31
- Output: -1
32
-
33
- Note:
34
- The given array will be in the range [1, 20000].
35
-
36
- */
37
3
public class _683 {
38
4
39
5
public static class Solution1 {
40
- /**credit: https://discuss.leetcode.com/topic/104771/java-c-simple-o-n-solution*/
6
+ /**
7
+ * credit: https://discuss.leetcode.com/topic/104771/java-c-simple-o-n-solution
8
+ */
41
9
public int kEmptySlots (int [] flowers , int k ) {
42
10
int [] days = new int [flowers .length ];
43
11
for (int i = 0 ; i < flowers .length ; i ++) {
You can’t perform that action at this time.
0 commit comments