package leetcode;

/**
 * https://leetcode.com/problems/merge-triplets-to-form-target-triplet/
 */
public class Problem1899 {
    public boolean mergeTriplets(int[][] triplets, int[] target) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem1899 prob = new Problem1899();
        System.out.println(prob.mergeTriplets(new int[][]{
            {2,5,3},
            {1,8,4},
            {1,7,5}
        }, new int[]{2,7,5})); // true
        System.out.println(prob.mergeTriplets(new int[][]{
            {1,3,4},
            {2,5,8}
        }, new int[]{2,5,8})); // true
        System.out.println(prob.mergeTriplets(new int[][]{
            {2,5,3},
            {2,3,4},
            {1,2,5},
            {5,2,3}
        }, new int[]{5,5,5})); // true
        System.out.println(prob.mergeTriplets(new int[][]{
            {2,5,3},
            {2,3,4},
            {1,2,5},
            {5,2,3}
        }, new int[]{5,5,3})); // true
        System.out.println(prob.mergeTriplets(new int[][]{
            {2,5,3},
            {2,3,4},
            {1,2,5},
            {5,2,3}
        }, new int[]{5,3,3})); // false
        System.out.println(prob.mergeTriplets(new int[][]{
            {2,5,3},
            {2,3,4},
            {1,2,5},
            {5,2,3}
        }, new int[]{1,5,3})); // false
        System.out.println(prob.mergeTriplets(new int[][]{
            {2,5,3},
            {2,3,4},
            {1,2,5},
            {5,2,3}
        }, new int[]{2,2,3})); // false
        System.out.println(prob.mergeTriplets(new int[][]{
            {2,5,3},
            {2,3,4},
            {1,2,5},
            {5,2,3}
        }, new int[]{2,3,3})); // false
        System.out.println(prob.mergeTriplets(new int[][]{
            {3,4,5},
            {4,5,6}
        }, new int[]{3,2,5})); // false
    }
}

@@ -198,796 +198,367 @@
     
-// TODO%0A        return false;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1899 prob = new Problem1899();%0A        System.out.println(prob.mergeTriplets(new int%5B%5D%5B%5D%7B%0A            %7B2,5,3%7D,%0A            %7B1,8,4%7D,%0A            %7B1,7,5%7D%0A        %7D, new int%5B%5D%7B2,7,5%7D)); // true%0A        System.out.println(prob.mergeTriplets(new int%5B%5D%5B%5D%7B%0A            %7B1,3,4%7D,%0A            %7B2,5,8%7D%0A        %7D, new int%5B%5D%7B2,5,8%7D)); // true%0A        System.out.println(prob.mergeTriplets(new int%5B%5D%5B%5D%7B%0A            %7B2,5,3%7D,%0A            %7B2,3,4%7D,%0A            %7B1,2,5%7D,%0A            %7B5,2,3%7D%0A        %7D, new int%5B%5D%7B5,5,5%7D)); // true%0A        System.out.println(prob.mergeTriplets(new int%5B%5D%5B%5D%7B%0A            %7B2,5,3%7D,%0A            %7B2,3,4%7D,%0A            %7B1,2,5%7D,%0A            %7B5,2,3%7D%0A        %7D, new int%5B%5D%7B5,5,3%7D)); //
+boolean%5B%5D valid = new boolean%5B3%5D;%0A        outer:%0A        for (int%5B%5D triplet : triplets) %7B%0A            boolean%5B%5D tmp = new boolean%5B3%5D;%0A            for (int i = 0; i %3C triplet.length; i++) %7B%0A                if (triplet%5Bi%5D %3E target%5Bi%5D) %7B%0A                    continue outer;%0A                %7D else if (triplet%5Bi%5D == target%5Bi%5D) %7B%0A                    tmp%5Bi%5D =
  true
+;
 %0A   
@@ -566,79 +566,17 @@
     
-System.out.println(prob.mergeTriplets(new int%5B%5D%5B%5D%7B%0A            %7B2,5,3%7D,
+        %7D
 %0A   
@@ -580,32 +580,25 @@
             
-%7B2,3,4%7D,
+%7D
 %0A           
@@ -602,359 +602,180 @@
     
-%7B1,2,5%7D,%0A            %7B5,2,3%7D%0A        %7D, new int%5B%5D%7B5,3,3%7D)); // false%0A        System.out.println(prob.mergeTriplets(new int%5B%5D%5B%5D%7B%0A            %7B2,5,3%7D,%0A            %7B2,3,4%7D,%0A            %7B1,2,5%7D,%0A            %7B5,2,3%7D%0A        %7D, new int%5B%5D%7B1,5,3%7D)); // false%0A        System.out.println(prob.mergeTriplets(new int%5B%5D%5B%5D%7B%0A            %7B2,5,3%7D,%0A            %7B2,3,4%7D,
+int validCount = 0;%0A            for (int i = 0; i %3C tmp.length; i++) %7B%0A                valid%5Bi%5D %7C= tmp%5Bi%5D;%0A                if (valid%5Bi%5D) %7B%0A                    validCount++;
 %0A   
@@ -779,32 +779,29 @@
             
-%7B1,2,5%7D,
+    %7D
 %0A           
@@ -793,38 +793,32 @@
   %7D%0A            
-%7B5,2,3
 %7D%0A        %7D, new
@@ -815,361 +815,109 @@
     
-%7D, new int%5B%5D%7B2,2,3%7D)); // false%0A        System.out.println(prob.mergeTriplets(new int%5B%5D%5B%5D%7B%0A            %7B2,5,3%7D,%0A            %7B2,3,4%7D,%0A            %7B1,2,5%7D,%0A            %7B5,2,3%7D%0A        %7D, new int%5B%5D%7B2,3,3%7D)); // false%0A        System.out.println(prob.mergeTriplets(new int%5B%5D%5B%5D%7B%0A            %7B3,4,5%7D,%0A            %7B4,5,6%7D%0A        %7D, new int%5B%5D%7B3,2,5%7D)); //
+    if (validCount == 3) %7B%0A                return true;%0A            %7D%0A        %7D%0A        return
  false
+;
 %0A   

Solve problem 1899