File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change 55
66public class _986 {
77 public static class Solution1 {
8- public int [][] intervalIntersection (int [][] A , int [][] B ) {
8+ public int [][] intervalIntersection (int [][] firstList , int [][] secondList ) {
99 int i = 0 ;
1010 int j = 0 ;
1111 List <int []> list = new ArrayList <>();
12- while (i < A .length && j < B .length ) {
13- int start = Math .max (A [i ][0 ], B [j ][0 ]);
14- int end = Math .min (A [i ][1 ], B [j ][1 ]);
12+ while (i < firstList .length && j < secondList .length ) {
13+ int start = Math .max (firstList [i ][0 ], secondList [j ][0 ]);
14+ int end = Math .min (firstList [i ][1 ], secondList [j ][1 ]);
1515 if (start <= end ) {
1616 list .add (new int []{start , end });
1717 }
18- if (end == A [i ][1 ]) {
18+ if (end == firstList [i ][1 ]) {
1919 i ++;
2020 } else {
2121 j ++;
2222 }
2323 }
24- int [][] result = new int [list .size ()][2 ];
25- for (int k = 0 ; k < list .size (); k ++) {
26- result [k ] = list .get (k );
27- }
28- return result ;
24+ return list .toArray (new int [list .size ()][2 ]);
2925 }
3026 }
3127}
You can’t perform that action at this time.
0 commit comments