Google | Phone screen | Shortest list of data centers
Anonymous User
836

Been recently asked this during one of interview. Thought to share.
You are given a map of datacenters to pop's.
datacenters = map[string][]string{
"aa":[]string{"pop1", "pop5", "pop7"},
"ab":[]string{"pop1", "pop2"},
"ba":[]string{"pop3", "pop5"},
}

You need to find the best possible (shortest) list of datacents for given list of pop's.
For example:
for [pop1] result would be "aa" or "ab".
for [pop1, pop5] result would be "aa".

Consider the following function interface:
function GetDataCenters(datacenters map[string][]string, findDCForPops []string) []string{...}
where datacenters is the map of datacenters in format specified above
and findDCForPops is the list of pops (pop1, pop2, pop5) to find datacenters for

Comments (4)