We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
publicstaticintbeautifulBinaryString(Stringb){//goal: determine min removals to a string not have 010intmin=0;for(inti=0;i<b.length()-2;i++){if(b.substring(i,i+3).equals("010")){min++;i+=2;// Skip next two characters to avoid overlapping patterns}}returnmin;}
Cookie support is required to access HackerRank
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 →
My Java solution: