You are viewing a single comment's thread. Return to all 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(); }
Seems like cookies are disabled on this browser, please enable them to open this website
Manasa and Sub-sequences
You are viewing a single comment's thread. Return to all comments →
Anyone has any ideas for optimizing my code in Java ? I have failed for the 2 last tests..