You are viewing a single comment's thread. Return to all comments →
Java solution
static boolean findPattern(int index, String b){ int n = b.length(); return (index < n - 2 && b.substring(index, index + 3).equals("010") ); } public static int beautifulBinaryString(String b) { int count = 0; int n = b.length(); int i = 0; while(i < n){ if(findPattern(i, b)){ count++; i += 3; } else i++; } return count; }
Seems like cookies are disabled on this browser, please enable them to open this website
Beautiful Binary String
You are viewing a single comment's thread. Return to all comments →
Java solution