Return array with elements present in both arrays, currently receiving a
not all node paths return a value
error. This is my code:
string[] findKnownsMergePattern(string[] vocab, string[] wds)
{
// TODO
List<string> results = new List<string>();
int xi = 0, yi = 0;
while (xi < wds.Length && yi < vocab.Length)
{
int cmp = wds[xi].CompareTo(vocab[yi]);
if (cmp == 0)
{
results.Add(vocab[yi++]);
}
else
{
xi++;
}
return results.ToArray();
}
}
In theory I think this should work just fine, I just can't seem to figure out why I'm getting the error.