You are viewing a single comment's thread. Return to all comments →
public static int beautifulBinaryString(String b) { // Write your code here String x; int count=0; char ch; for(int i=0;i<=b.length()-3;i++){ x=b.substring(i, i+3); if(i+3<b.length()){ ch=b.charAt(i+3); }else{ ch=x.charAt(1); } if(x.equals("010")){ b=b.replaceFirst(x, ""+ch+ch+ch); count++; } } 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