随笔分类 - 算法
摘要:题目: 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
阅读全文
摘要: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
阅读全文

浙公网安备 33010602011771号