Skip to content

Commit 012acab

Browse files
authored
Create 4056. Number of Intersecting Interval Pairs I.java
1 parent 52f85aa commit 012acab

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
public int countIntersections(int[][] intervals) {
3+
int count = 0;
4+
5+
for (int i = 0; i < intervals.length - 1; i++) {
6+
for (int j = i + 1; j < intervals.length; j++) {
7+
if (Math.max(intervals[i][0], intervals[j][0])
8+
<= Math.min(intervals[i][1], intervals[j][1])) {
9+
count++;
10+
}
11+
}
12+
}
13+
14+
return count;
15+
}
16+
}

0 commit comments

Comments
 (0)