Algorithm · Square · Medium
You are given a collection of records. Every record identifies two people and includes two strings: one indicating whether the first person likes the second, and one indicating whether the second person likes the first. Part 1: For a pair of people X and Y, report the number of times X likes Y across all the records. Part 2: Define the best friend of a person X as the person whom X likes the most often. Using this definition, recommend a person Z to X whenever Z is the best…