356 Line Reflection
Last updated
Last updated
class Solution {
public boolean isReflected(int[][] points) {
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
Set<String> set = new HashSet<>();
for (int[] point : points) {
max = Math.max(max, point[0]);
min = Math.min(min, point[0]);
String code = point[0] + "#" + point[1];
set.add(code);
}
int sum = min + max;
for (int[] point : points) {
String code = (sum - point[0]) + "#" + point[1];
if (!set.contains(code)) {
return false;
}
}
return true;
}
}