private boolean isValid(int s, int i, int j, String num) {
        if (j == num.length()) return true;
        if (num.charAt(s) == '0' && i - s > 1) return false;
        if (num.charAt(i) == '0' && j - i > 1) return false;
        BigInteger a = new BigInteger(num.substring(s, i));
        BigInteger b = new BigInteger(num.substring(i, j));
        String sum = a.add(b).toString();
        return num.startsWith(sum, j) && isValid(i, j, j + sum.length(), num);
    }