随笔分类 -  算法

摘要:题目: Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the t 阅读全文
posted @ 2017-12-06 18:28 Genesisx 阅读(188) 评论(0) 推荐(0)
摘要:1、二分查找算法 时间复杂度 比如:总共有n个元素,每次查找的区间大小就是n,n/2,n/4,…,n/2^k(接下来操作元素的剩余个数),其中k就是循环的次数。 由于n/2^k取整后>=1,即令n/2^k=1, 可得k=log2n,(是以2为底,n的对数),所以时间复杂度可以表示O()=O(logn 阅读全文
posted @ 2017-09-10 10:33 Genesisx 阅读(997) 评论(0) 推荐(0)