Implemented countCharOccurrences function.