摘要:
Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using ext... 阅读全文
摘要:
三步反转法 阅读全文
摘要:
二有序数组常用二分法, 要判断数组是否越界, 而数组的题常用递归, 擦半的方法, 比快排的方法, 少一个partition 遍历, 但是还是分成logn 层, Lintcode: Nuts & Bolts Problem 关键在于找到合适的比较位置, 准备擦出哪个数组的一半, 防止数组越界 The 阅读全文
摘要:
sorted 数组, 常用二指针遍历, 会倒叙, 会前序 逆序遍历的好处, 1只遍历后面的 2此题在于空间上可以不干扰. 阅读全文
摘要:
有序数组的题, 二分法, 根据mid的位置再确定start 和end的位置, 画图分情况 三种情况 The idea is that when rotating the array, there must be one half of the array that is still in sorte 阅读全文
摘要:
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume NO duplicates in the array. ... 阅读全文
摘要:
while-loop 要非递归写很简单,就用循环, 如果很复杂,就要用递归. but while 容易死循环 看不出就画图 二分法的模板- 阅读全文
摘要:
两个数组两个指针 两个数组的题常sort, 再通过两指针遍历 常常与0 的差的正负来判断, 来判断指针的走位, 此处直接判断大小更方便 阅读全文