public static String[] trim(String s0, String s1) {
        // Find the common prefix s.s0[0..h+1] and s.s[0.k+1]
        int h= 0;
        while (h < s0.length()  &&  h < s1.length()  &&
                s0.charAt(h) == s1.charAt(h)) {
            h= h+1;
        }
        s0= s0.substring(h);
        s1= s1.substring(h);

        // Find the common suffix s.s0[h+1..] and s.s1[k+1..]
        h= s0.length()-1;
        int k= s1.length()-1;
        while (0 <= h  && 0 <= k  &&
                s0.charAt(h) == s1.charAt(k)) {
            h= h-1;  k= k-1;
        }
        return new String[] {s0.substring(0, h+1), s1.substring(0, k+1)};
    }