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