#200. commonTwo
commonTwo
Background
Description
Start with two arrays of strings, a and b, each in alphabetical order, possibly with duplicates. Return the count of the number of strings which appear in both arrays. The best "linear" solution makes a single pass over both arrays, taking advantage of the fact that they are in alphabetical order.
Format
Input
Output
Samples
"a" "c" "x"] ["b" "c" "d" "x"
2
"a" "c" "x"] ["a" "b" "c" "x" "z"
3
"a" "b" "c"] ["a" "b" "c"
3
Limitation
1s, 1024KiB for each test case.