Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int countCode(String str) {
- int counter=0;
- for (int i = 0; i<=str.length(); i++){
- // if(str.equals("cozfxxcope")){
- //counter = 1;
- //break;} // I got stuck...
- int c = str.indexOf("c", i);
- int o = str.indexOf("o", i);
- int e = str.indexOf("e", i+1);
- if ((c+1 == o) && (o+2 == e) && (e-3 ==c) && (c != -1)){
- counter++;
- i+=3;
- }
- }
- return counter;
- }
Add Comment
Please, Sign In to add comment