import java.util.HashMap;
import java.util.Map;
class Solution {
public int solution(int[][] lines) {
int answer = 0;
Map<String, Integer> map = new HashMap<String, Integer>();
for (int[] line : lines) {
int tempMin = Math.min(line[0], line[1]);
int tempMax = Math.max(line[0], line[1]);
for (int i = tempMin + 1; i < tempMax + 1; i++) {
String str = (i - 1) + "/" + i;
map.put(str, map.getOrDefault(str, 0) + 1);
}
}
for (Integer value : map.values()) {
if (value > 1) answer++;
}
return answer;
}
}
class Solution {
public int solution(int[][] lines) {
int answer = 0;
int[] lineArr = new int[200];
for (int[] line : lines) {
int tempMin = Math.min(line[0], line[1]);
int tempMax = Math.max(line[0], line[1]);
for (int i = tempMin; i < tempMax + 1; i++) {
lineArr[i + 100]++;
}
}
for (int i = 1; i < lineArr.length; i++) {
if (lineArr[i - 1] > 1 && lineArr[i] > 1) {
answer++;
}
}
return answer;
}
}