Skip to content

Commit e380fbc

Browse files
committed
fd
1 parent bb6bc60 commit e380fbc

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

solution/src/main/java/com/inuker/solution/FindMedianFromDataStream.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.inuker.solution;
22

33
import java.util.Collections;
4+
import java.util.Comparator;
45
import java.util.PriorityQueue;
56

67
/**
@@ -17,7 +18,7 @@ public class FindMedianFromDataStream {
1718
/**
1819
* 比较小的一半
1920
*/
20-
PriorityQueue<Integer> minheap = new PriorityQueue<Integer>(Collections.reverseOrder());
21+
PriorityQueue<Integer> minheap = new PriorityQueue<Integer>(Comparator.reverseOrder());
2122

2223
// Adds a number into the data structure.
2324
public void addNum(int num) {

test/src/main/java/com/inuker/test/main.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,4 @@ public static void main(String[] args) {
2929
test.call("hello");
3030
test.call("how");
3131
}
32-
33-
public int lengthOfLongestSubstringKDistinct(String s, int k) {
34-
int longest = 0;
35-
int[] dp = new int[256];
36-
for (int i = 0, j = 0, n = 0; j < s.length(); j++) {
37-
char c = s.charAt(j);
38-
if (dp[c]++ == 0) {
39-
for (++n; i <= j && n > k; i++) {
40-
if (--dp[s.charAt(i)] == 0) {
41-
n--;
42-
}
43-
}
44-
}
45-
longest = Math.max(longest, j - i + 1);
46-
}
47-
return longest;
48-
}
4932
}

0 commit comments

Comments
 (0)