摘要:
Implementint sqrt(int x).Compute and return the square root ofx.Hide TagsMathBinary Search 并未使用牛顿迭代,实现是通过二分搜索实现的,需要注意判断时候 x* xusing namespace std;c... 阅读全文
摘要:
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... 阅读全文
摘要:
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],... 阅读全文
摘要:
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... 阅读全文
摘要:
Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ... 阅读全文
摘要:
Sort a linked list inO(nlogn) time using constant space complexity.Hide TagsLinked ListSort 基于单项链表的排序,时间为nlogn ,O(1)空间,其实及将数组的快速排序用链表实现,并用递归来维护拆分与合并。... 阅读全文
摘要:
c++ 函数的返回类型,包括const 什么时候起作用呢?函数返回值不想其立即修改的。 例子如下,这是一个简单的避免产生隐形返回变量的方法,abc 的函数返回是引用,main函数中第10行,++ 操作是基于 const int & 类型,所以会出错,但以后对改引用的操作不会受到const 约束... 阅读全文
摘要:
Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["255.2... 阅读全文
摘要:
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... 阅读全文
摘要:
Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express... 阅读全文