Mutual follows

Write code · Medium · §4.2 Pairs as keys

You are given the follow records follows. [a, b] means that a follows b. When two people follow each other, it is called a mutual follow.

Complete the function solution, which returns the number of mutual-follow pairs. The same record does not appear twice, and there is no record of a person following themselves.

Function

solution(follows)

Constraints

Examples

followsresult
[[1, 2], [2, 1], [1, 3]]1
[[1, 2], [2, 3], [3, 1]]0

Starter code

def solution(follows):
    answer = 0
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.