Leetcode 2085: Count Common Words With One Occurrence

In this Leetcode problem, we want to know which word occurs exactly once in each of the 2 lists of words provided.

Given two string arrays words1 and words2, return the number of strings that appear exactly once in each of the two arrays.

These are the couple of examples provided:

Examples and contraints

Solution idea