您的位置:首页 > 其它

HT349IntersectionOfTwoArray

2016-11-01 05:20 134 查看
Should give three ways, by the tags

First time write binary search, but can be optimized.

Faults

When comparing sorted array, I only considered the equal condition of two numbers, while the bigger and smaller can be used as the increment condition as well.

Under this situation –>,
if (array1[i] < array2[j])
or something, the increment must be executed after the assertion that
i < array1.size() and j < array2.size()


–> If we don’t want duplicate element in the result, we can use set to hold the result, rather than checking the last element in the result.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息