这道题我们要看清了,是平行于Y轴,而不是X轴。我知道我们很累,但也要看清楚题啊!!!
public class Solution {
public boolean isReflected(int[][] points) {
int max = Integer.MIN_VALUE, min = Integer.MAX_VALUE;
if (points == null || points.length == 0) {
return true;
}
Map<Integer, Set<Integer>> map = new HashMap<>();
for (int[] point: points) {
max = Math.max(point[0], max);
min = Math.min(point[0], min);
if (map.containsKey(point[1])) {
Set<Integer> set = map.get(point[1]);
set.add(point[0]);
} else {
Set<Integer> set = new HashSet<>();
set.add(point[0]);
map.put(point[1], set);
}
}
for (int[] point: points) {
Set<Integer> set = map.get(point[1]);
if (!set.contains(max + min - point[0])) {
return false;
}
}
return true;
}
}