package leetcode;

import java.util.List;

/**
 * https://leetcode.com/problems/remove-comments/
 */
public class Problem722 {
    public List<String> removeComments(String[] source) {
        return null;
    }

    public static void main(String[] args) {
        Problem722 prob = new Problem722();
        System.out.println(prob.removeComments(new String[]{
            "/*Test program */",
            "int main()", "{ ",
            "  // variable declaration ",
            "int a, b, c;",
            "/* This is a test",
            "   multiline  ",
            "   comment for ",
            "   testing */",
            "a = b + c;", "}"})); // ["int main()","{ ","  ","int a, b, c;","a = b + c;","}"]
        System.out.println(prob.removeComments(new String[]{"a/*comment", "line", "more_comment*/b"})); // [ab]
    }
}

@@ -12,16 +12,44 @@
 tcode;%0A%0A
+import java.util.ArrayList;%0A
 import j
@@ -63,16 +63,16 @@
 l.List;%0A
-
 %0A/**%0A * 
@@ -218,19 +218,1205 @@
     
-return null
+List%3CString%3E result = new ArrayList%3C%3E();%0A        boolean skip = false;%0A        StringBuilder sb = new StringBuilder();%0A        for (int i = 0; i %3C source.length; i++) %7B%0A            String src = source%5Bi%5D;%0A            int j = 0;%0A            outer:%0A            for (; j %3C src.length(); j++) %7B%0A                if (j + 1 %3C src.length() && src.charAt(j) == '/') %7B%0A                    if (!skip && src.charAt(j + 1) == '/') %7B%0A                        skip = false;%0A                        break outer;%0A                    %7D else if (!skip && src.charAt(j + 1) == '*') %7B%0A                        skip = true;%0A                        j++;%0A                    %7D%0A                %7D else if (j + 1 %3C src.length() && src.charAt(j) == '*') %7B%0A                    if (skip && src.charAt(j + 1) == '/') %7B%0A                        skip = false;%0A                        j += 2;%0A                    %7D%0A                %7D%0A                if (!skip && j %3C src.length()) %7B%0A                    sb.append(src.charAt(j));%0A                %7D%0A            %7D%0A            if (sb.length() %3E 0 && !skip) %7B%0A                result.add(sb.toString());%0A                sb = new StringBuilder();%0A            %7D%0A        %7D%0A        return result
 ;%0A  
@@ -1628,16 +1628,28 @@
 main()%22,
+%0A           
  %22%7B %22,%0A 
@@ -1865,16 +1865,28 @@
 b + c;%22,
+%0A           
  %22%7D%22%7D));
@@ -2010,58 +2010,858 @@
 g%5B%5D%7B
-%22a/*comment%22, %22line%22, %22more_comment*/b%22%7D)); // %5Bab
+%0A            %22a/*comment%22,%0A            %22line%22,%0A            %22more_comment*/b%22%7D)); // %5Bab%5D%0A        System.out.println(prob.removeComments(new String%5B%5D%7B%0A            %22a/b/*comment*/c+d/*%22,%0A            %22line%22,%0A            %22more_comment*/b%22%7D)); // %5Ba/bc+db%5D%0A        System.out.println(prob.removeComments(new String%5B%5D%7B%0A            %22void func(int k) %7B%22,%0A            %22// this function does nothing /*%22,%0A            %22   k = k*2/4;%22,%0A            %22   k = k/2;*/%22, %22%7D%22%0A        %7D)); // %5B%22void func(int k) %7B%22,%22   k = k*2/4;%22,%22   k = k/2;*/%22,%22%7D%22%5D%0A        System.out.println(prob.removeComments(new String%5B%5D%7B%0A            %22a//*b/*/c%22,%0A            %22blank%22,%0A            %22d/*/e/*/f%22%0A        %7D)); // %5B%22a%22,%22blank%22,%22df%22%5D%0A        System.out.println(prob.removeComments(new String%5B%5D%7B%0A            %22a/*/b//*c%22,%0A            %22blank%22,%0A            %22d//*e/*/f%22%0A        %7D)); // %5B%22af%22
 %5D%0A  

Update problem 722