Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Count Character Frequencies
00:00
5 left

Count Character Frequencies

EasyPython

Problem

Count the frequencies of chars in the char array.

Implement count_char_frequencies(char_array) to return a dictionary mapping each character to its number of occurrences. Matching is case-sensitive, and each array element contains exactly one character. Return an empty dictionary for an empty array.

Function signature: def count_char_frequencies(char_array): The output is a dictionary from characters to integer counts.

Constraints

  • 0 <= len(char_array) <= 1000
  • Each element of char_array is a string containing exactly one character
  • Matching is case-sensitive

Function Signature

def count_char_frequencies(char_array):
Interviewer

Your question is Count Character Frequencies. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.