VB.NET Array Intersection

后端 未结 4 905
无人及你
无人及你 2021-01-07 00:31

This could be terribly trivial, but I\'m having trouble finding an answer that executes in less than n^2 time. Let\'s say I have two string arrays and I want to know which s

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-07 01:34

    The simple way (assuming no .NET 3.5) is to dump the strings from one array in a hashtable, and then loop through the other array checking against the hashtable. That should be much faster than an n^2 search.

提交回复
热议问题