package leetcode;

/**
 * https://leetcode.com/problems/regular-expression-matching/
 */
public class Problem10 {
    public boolean isMatch(String s, String p) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem10 prob = new Problem10();
        System.out.println(prob.isMatch("aa", "a")); // false
        System.out.println(prob.isMatch("aa", "aa")); // true
        System.out.println(prob.isMatch("aaa", "aa")); // false
        System.out.println(prob.isMatch("aa", "a*")); // true
        System.out.println(prob.isMatch("aa", ".*")); // true
        System.out.println(prob.isMatch("ab", ".*")); // true
        System.out.println(prob.isMatch("aab", "c*a*b")); // true
    }
}

@@ -168,36 +168,701 @@
     
-// TODO%0A        return false
+return isMatch(s, p, 0, 0);%0A    %7D%0A%0A    private static boolean isMatch(String s, String p, int i, int j) %7B%0A        if (i == s.length() && j == p.length()) %7B%0A            return true;%0A        %7D%0A        if (i %3E= s.length() %7C%7C j %3E= p.length()) %7B%0A            return false;%0A        %7D%0A        boolean match = false;%0A        if (p.charAt(j) == '*') %7B%0A            if (s.charAt(i) == p.charAt(j - 1)) %7B%0A                match %7C= isMatch(s, p, i + 1, j);%0A            %7D%0A            match %7C= isMatch(s, p, i + 1, j + 1);%0A        %7D else %7B%0A            if (s.charAt(i) != p.charAt(j)) %7B%0A                return false;%0A            %7D%0A            match %7C= isMatch(s, p, i + 1, j + 1);%0A        %7D%0A        return match
 ;%0A  
@@ -953,16 +953,18 @@
 em10();%0A
+//
         
@@ -1009,32 +1009,34 @@
 %22a%22)); // false%0A
+//
         System.o
@@ -1073,32 +1073,34 @@
 %22aa%22)); // true%0A
+//
         System.o
@@ -1147,16 +1147,18 @@
 / false%0A
+//
         
@@ -1203,32 +1203,34 @@
 %22a*%22)); // true%0A
+//
         System.o
@@ -1267,32 +1267,34 @@
 %22.*%22)); // true%0A
+//
         System.o
@@ -1335,24 +1335,26 @@
 )); // true%0A
+//
         Syst
@@ -1407,16 +1407,150 @@
 // true%0A
+        System.out.println(prob.isMatch(%22caab%22, %22c*a*b%22)); // true%0A//        System.out.println(prob.isMatch(%22abb%22, %22a.*b%22)); // true%0A
     %7D%0A%7D%0A

Update problem 10