We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 54630ee commit e3c03e0Copy full SHA for e3c03e0
src/arrays/MergeOverlaps.java
@@ -43,16 +43,35 @@ public static void main(String args[]){
43
test.add(tuple5);
44
test.add(tuple6);
45
46
- System.out.println(test);
47
-
48
merge_overlaps(test);
49
50
+ System.out.println(test);
51
}
52
53
private static void merge_overlaps(ArrayList<Tuple> test) {
54
55
+ int start = test.get(0).x;
+ int end = test.get(0).y;
+ int i = 1;
56
+ while(i<test.size()){
57
+
58
+ int curr_start = test.get(i).x;
59
+ int curr_end = test.get(i).y;
60
61
+ if (curr_start<end){
62
+ end = Math.max(end, curr_end);
63
+ test.set(i, new Tuple(start,end));
64
+ test.remove(i-1);
65
66
+ } else{
67
+ start = curr_start;
68
+ end = curr_end;
69
+ i++;
70
+ }
71
72
+ //uncomment the following command to keep track
73
+ //System.out.println(test+" start: "+start+" end: "+end+" curr_start: "+curr_start+" curr_end: "+curr_end+" i:"+i);
74
75
76
77
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments