摘要: 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 or... 阅读全文
posted @ 2014-11-20 11:37 雄哼哼 阅读(158) 评论(0) 推荐(0) 编辑
摘要: ①链表反转单向链表的反转是一个经常被问到的一个面试题,也是一个非常基础的问题。比如一个链表是这样的: 1->2->3->4->5 通过反转后成为5->4->3->2->1。最容易想到的方法遍历一遍链表,利用一个辅助指针,存储遍历过程中当前指针指向的下一个元素,然后将当前节点元素的指针反转后,利用已经... 阅读全文
posted @ 2014-11-20 10:53 雄哼哼 阅读(404) 评论(0) 推荐(0) 编辑
摘要: Divide two integers without using multiplication, division and mod operator.由于不能用乘号,除号,和取余。那么一个数除另外一个数,如a/b,实际含义是a中有多少个b,我们可以多次计算a-b,并更新a,最后a-b>1; ... 阅读全文
posted @ 2014-11-20 10:44 雄哼哼 阅读(276) 评论(0) 推荐(0) 编辑