You are viewing a single comment's thread. Return to all comments →
Solution worked to 7 test. Java 8
static HashSet<String> set; static { set = new HashSet<>(); int n = 800; set.add("1"); for (int i = 0; i <= n - 1; ++i) { set.add(BigInteger.ONE.shiftLeft(i).toString()); } } static int twoTwo(String s){ int count = 0; for (int i = 0; i < s.length();i++){ if (s.charAt(i)=='0') continue; for (int j = i; j < s.length(); j++) { if (set.contains(s.substring(i,j+1))){ count++; } } } System.out.println(count); return count; }
Seems like cookies are disabled on this browser, please enable them to open this website
Two Two
You are viewing a single comment's thread. Return to all comments →
Solution worked to 7 test. Java 8