Given two lists of integers, a and b, return how many different values appear in both of them.
A value counts only once, however many times it appears in a or in b.
Example 1:
Input: a = [1, 2, 3, 4], b = [3, 4, 5] Output: 2 Explanation: 3 and 4 are in both. 1 and 2 are only in a, and 5 is only in b.
Example 2:
Input: a = [7, 7, 8], b = [7, 9, 7] Output: 1 Explanation: 7 is the only value in both. It appears twice in each, but it counts once.
Example 3:
Input: a = [1, 2], b = [3, 4] Output: 0 Explanation: No value is in both.
Constraints:
aandbeach have at least one number.- Every number is between -109 and 109.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
