package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/flower-planting-with-no-adjacent/
 */
public class Problem1042 {
    public int[] gardenNoAdj(int N, int[][] paths) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1042 prob = new Problem1042();
        System.out.println(Arrays.toString(prob.gardenNoAdj(3, new int[][]{{1, 2}, {2, 3}, {3, 1}}))); // [1,2,3]
        System.out.println(Arrays.toString(prob.gardenNoAdj(4, new int[][]{{1, 2}, {3, 4}}))); // [1,2,1,2]
        System.out.println(Arrays.toString(prob.gardenNoAdj(4, new int[][]{{1, 2}, {2, 3}, {3, 4}, {4, 1}, {1, 3}, {2, 4}}))); // [1,2,3,4]
    }
}

@@ -36,16 +36,64 @@
 .Arrays;
+%0Aimport java.util.HashSet;%0Aimport java.util.Set;
 %0A%0A/**%0A *
@@ -237,24 +237,407 @@
 %5B%5D paths) %7B%0A
+        Set%3CInteger%3E%5B%5D set = new HashSet%5BN + 1%5D;%0A        for (int i = 1; i %3C= N; i++) %7B%0A            set%5Bi%5D = new HashSet%3C%3E();%0A        %7D%0A        for (int i = 1; i %3C= N; i++) %7B%0A            int a = paths%5Bi%5D%5B0%5D;%0A            int b = paths%5Bi%5D%5B1%5D;%0A            set%5Ba%5D.add(b);%0A            set%5Bb%5D.add(a);%0A        %7D%0A        int%5B%5D answer = new int%5BN%5D;%0A        for (int i = 1; i %3C= N; i++) %7B%0A    
         // T
@@ -640,16 +640,26 @@
 // TODO%0A
+        %7D%0A
         
@@ -669,12 +669,14 @@
 urn 
-null
+answer
 ;%0A  
@@ -885,16 +885,18 @@
 %5B1,2,3%5D%0A
+//
         
@@ -995,16 +995,18 @@
 ,2,1,2%5D%0A
+//
         

Update problem 1042