Skip to content

Commit 81faf43

Browse files
refactor 683
1 parent ac98581 commit 81faf43

File tree

1 file changed

+3
-35
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+3
-35
lines changed

src/main/java/com/fishercoder/solutions/_683.java

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,11 @@
11
package com.fishercoder.solutions;
22

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-
*/
373
public class _683 {
384

395
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+
*/
419
public int kEmptySlots(int[] flowers, int k) {
4210
int[] days = new int[flowers.length];
4311
for (int i = 0; i < flowers.length; i++) {

0 commit comments

Comments
 (0)