package leetcode;

/**
 * https://leetcode.com/problems/valid-square/
 */
public class Problem593 {
    public boolean validSquare(int[] p1, int[] p2, int[] p3, int[] p4) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem593 prob = new Problem593();
        System.out.println(prob.validSquare(new int[]{0, 0}, new int[]{1, 1}, new int[]{1, 0}, new int[]{0, 1})); // true
    }
}

@@ -12,16 +12,68 @@
 tcode;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.List;%0A%0A
 /**%0A * h
@@ -230,15 +230,1457 @@
     
-// TODO
+List%3Cint%5B%5D%3E list = new ArrayList%3C%3E();%0A        list.add(p2);%0A        list.add(p3);%0A        list.add(p4);%0A        int%5B%5D a = p1;%0A        for (int i = 0; i %3C list.size(); i++) %7B%0A            int%5B%5D b = list.get(i);%0A            if (a%5B0%5D == b%5B0%5D) %7B%0A                // a %3C--%3E b (y-axis)%0A                int dist1 = Math.abs(a%5B1%5D - b%5B1%5D);%0A                list.remove(i);%0A                int%5B%5D c = null;%0A                for (int j = 0; j %3C list.size(); j++) %7B%0A                    if (a%5B1%5D == list.get(j)%5B1%5D) %7B%0A                        c = list.get(j);%0A                        list.remove(j);%0A                        break;%0A                    %7D%0A                %7D%0A                if (c == null) %7B%0A                    return false;%0A                %7D%0A                // a %3C--%3E c (x-axis)%0A                int dist2 = Math.abs(a%5B0%5D - c%5B0%5D);%0A                if (dist1 != dist2) %7B%0A                    return false;%0A                %7D%0A                int%5B%5D d = list.get(0);%0A                if (b%5B1%5D != d%5B1%5D) %7B%0A                    return false;%0A                %7D%0A                // b %3C--%3E d (x-axis)%0A                int dist3 = Math.abs(b%5B0%5D - d%5B0%5D);%0A                if (dist2 != dist3) %7B%0A                    return false;%0A                %7D%0A                // c %3C--%3E d (y-axis)%0A                int dist4 = Math.abs(c%5B1%5D - d%5B1%5D);%0A                if (dist3 != dist4) %7B%0A                    return false;%0A                %7D%0A                return true;%0A            %7D%0A        %7D
 %0A   
@@ -1790,24 +1790,26 @@
 oblem593();%0A
+//
         Syst
@@ -1918,16 +1918,515 @@
 // true%0A
+//        System.out.println(prob.validSquare(new int%5B%5D%7B0, 0%7D, new int%5B%5D%7B1, 1%7D, new int%5B%5D%7B1, 5%7D, new int%5B%5D%7B0, 1%7D)); // false%0A//        System.out.println(prob.validSquare(new int%5B%5D%7B0, 1%7D, new int%5B%5D%7B0, 0%7D, new int%5B%5D%7B1, 1%7D, new int%5B%5D%7B1, 0%7D)); // true%0A//        System.out.println(prob.validSquare(new int%5B%5D%7B0, 1%7D, new int%5B%5D%7B0, 0%7D, new int%5B%5D%7B1, -1%7D, new int%5B%5D%7B1, 0%7D)); // false%0A        System.out.println(prob.validSquare(new int%5B%5D%7B1, 0%7D, new int%5B%5D%7B-1, 0%7D, new int%5B%5D%7B0, 1%7D, new int%5B%5D%7B0, -1%7D)); // true%0A
     %7D%0A%7D%0A

Update problem 593