← 返回 linkedin 的题目列表Calculate Candidate Connection Distance
类型:online_judge
Given an interface Candidate with a method list<Candidate> getConnections(), implement a method int getDistance(Candidate c1, Candidate c2) to calculate the shortest connection distance between two candidates. Return -1 if no connection exists. Implement this method using BFS. Discuss how to optimize and design this algorithm for production scale.
Example
Input
Candidate A, Candidate B