I have got ‘n’ rows of data sets, each data set having two components separated by space. First is card number and second is name. A person is same, if he has same card number or the name. How to find the total number of unique person from the data set?
Example:
1 A
1 B
2 B
3 C
This data set has 2 unique person. This is because the first and second row card number is same and second and third row name is same.
What kind of algorithms can be used to solve this kind of problem?
The solution I came up with is using some sort of partitioning: Most operation are done in O(1) or O(logn) and it is done once by user, therefor the time complexity is about O(n),O(logn) depending on how Dictionary are implemented.