Skip to content

Instantly share code, notes, and snippets.

@gcrfelix
Created October 25, 2015 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gcrfelix/8551ecbac026a900c2de to your computer and use it in GitHub Desktop.
Save gcrfelix/8551ecbac026a900c2de to your computer and use it in GitHub Desktop.
给两个sorted array, 返回它们两个包含的相同元素,比如[2, 3, 4], [1, 2, 3, 5] 返回[2, 3]
然后追加的是如果其中一个array特别长一个比较短怎么做
解法:
对短数组里的每个元素在长数组里进行二分查找 当然,二分查找的空间也是逐步缩小的,虽然算法复杂度不会变
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment