package leetcode;

/**
 * https://leetcode.com/problems/validate-binary-tree-nodes/
 */
public class Problem1361 {
    public boolean validateBinaryTreeNodes(int n, int[] leftChild, int[] rightChild) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem1361 prob = new Problem1361();
        System.out.println(prob.validateBinaryTreeNodes(4, new int[]{1,-1,3,-1}, new int[]{2,-1,-1,-1})); // true
        System.out.println(prob.validateBinaryTreeNodes(4, new int[]{1,-1,3,-1}, new int[]{2,3,-1,-1})); // false
        System.out.println(prob.validateBinaryTreeNodes(2, new int[]{1,0}, new int[]{-1,-1})); // false
        System.out.println(prob.validateBinaryTreeNodes(6, new int[]{1,-1,-1,4,-1,-1}, new int[]{2,-1,-1,5,-1,-1})); // false
        System.out.println(prob.validateBinaryTreeNodes(5, new int[]{3,-1,-1,1,-1}, new int[]{4,-1,-1,2,-1})); // false
    }
}

@@ -207,35 +207,755 @@
     
-// TODO%0A        return fals
+int%5B%5D inCount = new int%5Bn%5D;%0A        int%5B%5D outCount = new int%5Bn%5D;%0A        for (int i = 0; i %3C n; i++) %7B%0A            // there should not be any edge going into the root%0A            if (leftChild%5Bi%5D == 0 %7C%7C rightChild%5Bi%5D == 0) %7B%0A                return false;%0A            %7D%0A            if (leftChild%5Bi%5D %3E 0) %7B%0A                outCount%5Bi%5D++;%0A                inCount%5BleftChild%5Bi%5D%5D++;%0A                if (inCount%5BleftChild%5Bi%5D%5D %3E 1) %7B%0A                    return false;%0A                %7D%0A            %7D%0A            if (rightChild%5Bi%5D %3E 0) %7B%0A                outCount%5Bi%5D++;%0A                inCount%5BrightChild%5Bi%5D%5D++;%0A                if (inCount%5BrightChild%5Bi%5D%5D %3E 1) %7B%0A                    return false;%0A                %7D%0A            %7D%0A        %7D%0A        return tru
 e;%0A 
@@ -1051,16 +1051,18 @@
 1361();%0A
+//
         
@@ -1167,16 +1167,18 @@
 // true%0A
+//
         
@@ -1275,32 +1275,34 @@
 -1%7D)); // false%0A
+//
         System.o
@@ -1381,32 +1381,145 @@
 -1%7D)); // false%0A
+//        System.out.println(prob.validateBinaryTreeNodes(3, new int%5B%5D%7B1,2,1%7D, new int%5B%5D%7B-1,-1,-1%7D)); // false%0A//
         System.o

Update problem 1361