12. String Dolphin

Count how many times “dolphin” appears in a string. Except don’t count the word “dolphin” if it comes immediately after “shark “.

public static int cdol(String str)

Examples:

  1. cdol("dolphin dolphin dolphin") => 3
  2. cdol("dolphin shark dolphin") => 1
Last modified August 18, 2023: 2022-2023 End State (7352e87)