File tree Expand file tree Collapse file tree 2 files changed +2
-18
lines changed
solution/src/main/java/com/inuker/solution
test/src/main/java/com/inuker/test Expand file tree Collapse file tree 2 files changed +2
-18
lines changed Original file line number Diff line number Diff line change 1
1
package com .inuker .solution ;
2
2
3
3
import java .util .Collections ;
4
+ import java .util .Comparator ;
4
5
import java .util .PriorityQueue ;
5
6
6
7
/**
@@ -17,7 +18,7 @@ public class FindMedianFromDataStream {
17
18
/**
18
19
* 比较小的一半
19
20
*/
20
- PriorityQueue <Integer > minheap = new PriorityQueue <Integer >(Collections .reverseOrder ());
21
+ PriorityQueue <Integer > minheap = new PriorityQueue <Integer >(Comparator .reverseOrder ());
21
22
22
23
// Adds a number into the data structure.
23
24
public void addNum (int num ) {
Original file line number Diff line number Diff line change @@ -29,21 +29,4 @@ public static void main(String[] args) {
29
29
test .call ("hello" );
30
30
test .call ("how" );
31
31
}
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
- }
49
32
}
You can’t perform that action at this time.
0 commit comments