上一页 1 2 3 4 5 6 ··· 15 下一页
摘要: Implementint sqrt(int x).Compute and return the square root ofx.Hide TagsMathBinary Search 并未使用牛顿迭代,实现是通过二分搜索实现的,需要注意判断时候 x* xusing namespace std;c... 阅读全文
posted @ 2015-03-24 18:01 A_zhu 阅读(191) 评论(0) 推荐(0) 编辑
摘要: Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the ord... 阅读全文
posted @ 2015-03-22 19:47 A_zhu 阅读(229) 评论(0) 推荐(0) 编辑
摘要: Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3],... 阅读全文
posted @ 2015-03-22 00:00 A_zhu 阅读(170) 评论(0) 推荐(0) 编辑
摘要: Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjace... 阅读全文
posted @ 2015-03-21 23:31 A_zhu 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ... 阅读全文
posted @ 2015-03-21 01:50 A_zhu 阅读(133) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list inO(nlogn) time using constant space complexity.Hide TagsLinked ListSort 基于单项链表的排序,时间为nlogn ,O(1)空间,其实及将数组的快速排序用链表实现,并用递归来维护拆分与合并。... 阅读全文
posted @ 2015-03-20 13:35 A_zhu 阅读(245) 评论(0) 推荐(0) 编辑
摘要: c++ 函数的返回类型,包括const 什么时候起作用呢?函数返回值不想其立即修改的。 例子如下,这是一个简单的避免产生隐形返回变量的方法,abc 的函数返回是引用,main函数中第10行,++ 操作是基于 const int & 类型,所以会出错,但以后对改引用的操作不会受到const 约束... 阅读全文
posted @ 2015-03-20 04:25 A_zhu 阅读(16960) 评论(0) 推荐(1) 编辑
摘要: Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["255.2... 阅读全文
posted @ 2015-03-20 00:04 A_zhu 阅读(222) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note... 阅读全文
posted @ 2015-03-17 23:23 A_zhu 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express... 阅读全文
posted @ 2015-03-17 23:08 A_zhu 阅读(229) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 15 下一页