79593472

Date: 2025-04-26 00:45:18
Score: 1
Natty:
Report link
public boolean catDog(String str) {
  int count = 0;
  for (int i=0; i < str.length() - 2; i++) {
    if (str.charAt(i) == 'c' &&
    str.charAt(i+1) == 'a' &&
    str.charAt(i+2) == 't') count++;
    if (str.charAt(i) == 'd' &&
    str.charAt(i+1) == 'o' &&
    str.charAt(i+2) == 'g') count--;
  } 
  return count == 0;
}
Reasons:
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Blake