Manasa and Sub-sequences

  • + 0 comments

    Anyone has any ideas for optimizing my code in Java ? I have failed for the 2 last tests..

    static long solve(String s) {
            BigInteger sum = BigInteger.valueOf(Character.getNumericValue(s.charAt(0)));
            for(int i=1;i<s.length();i++){
                sum = sum.multiply(BigInteger.valueOf(11)).add(BigInteger.valueOf(2).pow(i).multiply(BigInteger.valueOf(Character.getNumericValue(s.charAt(i)))));
            }
            return sum.mod(BigInteger.valueOf(1000000007)).longValue();
        }