less than 1 minute read

Given two strings s0 and s1, each representing a sentence, return the number of unique words that are shared between the two sentences.

Note: words are case-insensitive so “hello” and “Hello” are the same word.

Constraints

  • n ≤ 100,000 where n is the length of s0
  • m ≤ 100,000 where m is the length of s1

https://binarysearch.com/problems/Common-Words

Examples

Example 1

Input

  • s0 = hello world hello oyster
  • s1 = world is your oyster

Output

  • answer = 2

Explanation

Only “world” and “oyster” are shared between the two sentences.

Solution

Leave a comment