Duplicate Baby Names Problem

Duplicate Baby Names Problem

Given two lists, one of names/frequencies and other of pairs of equivalent names (synonyms), implement an algorithm to print a new list of the true frequency of each name.

Note: Name relationship is both transitive and symmetric.


  • There are various ways to solve this problem
    • Using disjoint set
    • Graph
Graph Implementation Algorithm:
  1. Create a undirected graph with node (name, frequency)
  2. Add edges between nodes of graph using synonyms
  3. Use DFS to add all frequencies of same names

Latest Source Code:
Github: BalancedBSTZeroSumFinder.java


Kris - 36
Johnny - 27
Author: Hrishikesh Mishra