Duplicate Count in Linear Time Java Coding Challenge | Edabit | How'd You Code That?

Опубликовано: 19 Июнь 2026
на канале: Ed Clark
26
5

Duplicate Count

Other videos like the Duplicate count java coding challenge:
   • No Duplicate Letters Java Coding Challenge...  

To solve this problem in linear time, I use two HashSets, one to determine when I've encountered a duplicate character, and the other to house the duplicates.
For each character in the incoming string, I’m inserting it into my first HashSet. If the add operation returns false, the character is a duplicate, so I insert it into my duplicates HashSet.
Once all characters have been processed, the size of the duplicates HashSet , which contains unique duplicates, is returned to the caller.

Song: Mystery - Ikson (Vlog No Copyright Music)
Music promoted by Vlog No Copyright Music.
  / ikson