Find common friends from directed edges | Microsoft Interview Question