File tree Expand file tree Collapse file tree 3 files changed +25
-10
lines changed
g1801_1900/s1825_finding_mk_average
g3401_3500/s3425_longest_special_path
test/java/g1801_1900/s1825_finding_mk_average Expand file tree Collapse file tree 3 files changed +25
-10
lines changed Original file line number Diff line number Diff line change 66import java .util .LinkedList ;
77import java .util .TreeSet ;
88
9- @ SuppressWarnings ("java:S2184" )
109public class MKAverage {
11- private int capacity ;
12- private int boundary ;
13- private int [] nums ;
14- private TreeSet <Integer > numSet ;
15- private LinkedList <Integer > order ;
10+ private final int capacity ;
11+ private final int boundary ;
12+ private final int [] nums ;
13+ private final TreeSet <Integer > numSet ;
14+ private final LinkedList <Integer > order ;
1615
1716 public MKAverage (int m , int k ) {
1817 this .capacity = m ;
@@ -63,7 +62,9 @@ public int calculateMKAverage() {
6362 }
6463}
6564
66- /**
67- * Your MKAverage object will be instantiated and called as such: MKAverage obj = new MKAverage(m,
68- * k); obj.addElement(num); int param_2 = obj.calculateMKAverage();
65+ /*
66+ * Your MKAverage object will be instantiated and called as such:
67+ * MKAverage obj = new MKAverage(m, k);
68+ * obj.addElement(num);
69+ * int param_2 = obj.calculateMKAverage();
6970 */
Original file line number Diff line number Diff line change 66import java .util .ArrayList ;
77import java .util .List ;
88
9- @ SuppressWarnings (" unchecked" )
9+ @ SuppressWarnings ({ "java:S107" , " unchecked"} )
1010public class Solution {
1111 public int [] longestSpecialPath (int [][] edges , int [] nums ) {
1212 int n = edges .length + 1 ;
Original file line number Diff line number Diff line change @@ -19,4 +19,18 @@ void mKAverage() {
1919 obj .addElement (5 );
2020 assertThat (obj .calculateMKAverage (), equalTo (5 ));
2121 }
22+
23+ @ Test
24+ void mKAverage2 () {
25+ MKAverage obj = new MKAverage (6 , 1 );
26+ obj .addElement (3 );
27+ obj .addElement (1 );
28+ assertThat (obj .calculateMKAverage (), equalTo (-1 ));
29+ obj .addElement (12 );
30+ assertThat (obj .calculateMKAverage (), equalTo (-1 ));
31+ obj .addElement (5 );
32+ obj .addElement (3 );
33+ obj .addElement (4 );
34+ assertThat (obj .calculateMKAverage (), equalTo (3 ));
35+ }
2236}
You can’t perform that action at this time.
0 commit comments