Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Count Letters in a String

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Count Letters in a String. Start with the requirements on the right.

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.

Problem

ZoomInfo SalesOS processes text fields that may contain names, labels, punctuation, and numeric identifiers. Write a function that counts each English alphabet character in a given string, treating uppercase and lowercase forms as the same character.

Return a dictionary containing only the letters that appear, with keys in alphabetical order. Ignore whitespace, digits, punctuation, and any character outside the English alphabet. The result must be produced with a single left-to-right scan of the input.

Formal Specification

Implement count_alphabets(text).

  • Input: text, a string containing ASCII letters, digits, whitespace, and punctuation.
  • Output: A dictionary mapping lowercase letters to their integer frequencies. Return {} when no English letters appear.

Constraints

  • 0 <= len(text) <= 10^6
  • Input contains ASCII characters
  • Only A-Z and a-z are counted
  • Matching is case-insensitive

Function Signature

def count_alphabets(text):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output