Common Words
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
wheren
is the length ofs0
m ≤ 100,000
wherem
is the length ofs1
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.
Leave a comment