package leetcode;

/**
 * https://leetcode.com/problems/masking-personal-information/
 */
public class Problem831 {
    public String maskPII(String S) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem831 prob = new Problem831();
        System.out.println(prob.maskPII("LeetCode@LeetCode.com")); // l*****e@leetcode.com
        System.out.println(prob.maskPII("AB@qq.com")); // a*****b@qq.com
        System.out.println(prob.maskPII("1(234)567-890")); // ***-***-7890
        System.out.println(prob.maskPII("86-(10)12345678")); // +**-***-***-5678
        System.out.println(prob.maskPII("1-(10)12345678")); // +*-***-***-5678
    }
}

@@ -159,35 +159,572 @@
     
-// TODO%0A        return null
+if (isEmail(S)) %7B%0A            return maskEmail(S);%0A        %7D%0A        return maskPhone(S);%0A    %7D%0A%0A    private static boolean isEmail(String s) %7B%0A        return s.contains(%22@%22);%0A    %7D%0A%0A    private static String maskEmail(String s) %7B%0A        StringBuilder sb = new StringBuilder();%0A        int idx = s.indexOf(%22@%22);%0A        sb.append(s.charAt(0));%0A        for (int i = 0; i %3C 4; i++) %7B%0A            sb.append(%22*%22);%0A        %7D%0A        sb.append(s.substring(idx - 1));%0A        return sb.toString();%0A    %7D%0A%0A    private static String maskPhone(String s) %7B%0A        return %22%22
 ;%0A  
@@ -977,24 +977,26 @@
 ***b@qq.com%0A
+//
         Syst
@@ -1058,16 +1058,18 @@
 **-7890%0A
+//
         
@@ -1137,24 +1137,26 @@
 **-***-5678%0A
+//
         Syst

Update problem 831