@@ -0,0 +1,1453 @@
+package com.flang.hashmap;%0A%0Aimport java.util.HashMap;%0Aimport java.util.HashSet;%0Aimport java.util.Map;%0A%0A/**%0A * LC 356%0A * Given n points on a 2D plane, find if there is such a line parallel to y-axis that reflect the given points.%0A *%0A * Example 1:%0A * Input: %5B%5B1,1%5D,%5B-1,1%5D%5D%0A * Output: true%0A *%0A * Example 2:%0A * Input: %5B%5B1,1%5D,%5B-1,-1%5D%5D%0A * Output: false%0A */%0Apublic class LineReflection %7B%0A%0A    public static boolean isReflected(int%5B%5D%5B%5D points) %7B%0A        if(points == null %7C%7C points.length %3C 2) %7B%0A            return true;%0A        %7D%0A        int max = Integer.MIN_VALUE;%0A        int min = Integer.MAX_VALUE;%0A        Map%3CInteger, HashSet%3CInteger%3E%3E map = new HashMap();%0A        for (int%5B%5D p : points) %7B%0A            max = Math.max(max, p%5B0%5D);%0A            min = Math.min(min, p%5B0%5D);%0A            HashSet%3CInteger%3E set = map.get(p%5B0%5D);%0A            if (set == null) %7B%0A                set = new HashSet%3C%3E();%0A                map.put(p%5B0%5D, set);%0A            %7D%0A            set.add(p%5B1%5D);%0A        %7D%0A        int y = max + min;%0A        for (int%5B%5D p : points) %7B%0A            int right = y - p%5B0%5D;%0A            if (!map.get(right).contains(p%5B1%5D) %7C%7C map.get(right) == null) %7B%0A                return false;%0A            %7D%0A        %7D%0A        return true;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        int%5B%5D%5B%5D points = new int%5B%5D%5B%5D%7B%7B5,1%7D, %7B1,1%7D%7D;%0A        System.out.println(isReflected(points));%0A        //System.out.println(isReflected(new int%5B%5D%5B%5D%7B%7B1,1%7D, %7B-1,-1%7D%7D));%0A    %7D%0A%7D%0A

Create LineReflection.java