Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Duplicate Characters Count
00:00
5 left

Duplicate Characters Count

EasyPython

Problem

Calculate the number of duplicates for each character in a string.

Treat uppercase and lowercase characters as distinct, and include spaces and punctuation as characters. Return a dictionary containing only characters that occur at least twice, with each character mapped to its total occurrence count. Preserve the order in which repeated characters first appear.

Function: def count_duplicate_characters(s):

Constraints

  • 0 <= len(s) <= 1000
  • s may contain letters, digits, whitespace, punctuation, and Unicode characters
  • Character comparison is case-sensitive
  • Return only characters with total frequency greater than 1

Function Signature

def count_duplicate_characters(s):
Interviewer

Your question is Duplicate Characters Count. 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.