Count the Number of Duplicate Characters

Published by Matt in

Create a function that takes a string and returns the number of alphanumeric characters that occur more than once.

Examples

duplicate_count("abcde") ➞ 0

duplicate_count("aabbcde") ➞ 2

duplicate_count("Indivisibilities") ➞ 2

duplicate_count("Aa") ➞ 0
# Case sensitive

Notes

  • Duplicate characters are case sensitive.
  • The input string will contain only alphanumeric characters.
Watch a quick demo on how Edabit works.