We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I agree - the question starts off asking for the number of city names that aren't unique. That is, the difference between (NUM) = the total # of city names is the # of distinct city names in the data set, and NUM{unique} = the # of city names that are used only once.
Yet other parts of the question asks for something else: the # of city entries that are using a city name beyond the first time, which is the total # of city entries (not names) less the total # of city names.
The difference manifests when there are more than 2 entries that use the same name. Given the data set:
(ID, NAME) =
(1, A)
(2, C)
(3, B)
(4, C)
(5, B)
(6, C)
(7, C)
The first "non-unique city names" ask yields 2: there are 3 city names (A,B,C) and only 1 is "unique" (A).
The entries ask yields 4: 7 entries less 3 names. It's 2 more than the other because (C) is used that many more times. I frankly don't find this ask very useful.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Weather Observation Station 4
You are viewing a single comment's thread. Return to all comments →
I agree - the question starts off asking for the number of city names that aren't unique. That is, the difference between (NUM) = the total # of city names is the # of distinct city names in the data set, and NUM{unique} = the # of city names that are used only once.
Yet other parts of the question asks for something else: the # of city entries that are using a city name beyond the first time, which is the total # of city entries (not names) less the total # of city names.
The difference manifests when there are more than 2 entries that use the same name. Given the data set:
(ID, NAME) = (1, A) (2, C) (3, B) (4, C) (5, B) (6, C) (7, C)
The first "non-unique city names" ask yields 2: there are 3 city names (A,B,C) and only 1 is "unique" (A).
The entries ask yields 4: 7 entries less 3 names. It's 2 more than the other because (C) is used that many more times. I frankly don't find this ask very useful.