Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ...
分类:
其他好文 时间:
2014-07-06 17:44:30
阅读次数:
181
Divide two integers without using multiplication, division and mod operator.思路:不能使用乘法除法以及取模运算来计算两个数相除。主要做法就是,将因子不断乘2(向左移位即可实现),同时结果从1不断移位加倍,等到除数大于被除数一...
分类:
其他好文 时间:
2014-07-06 15:34:24
阅读次数:
197
Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation...
分类:
其他好文 时间:
2014-07-06 13:57:54
阅读次数:
155
Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all distinc...
分类:
其他好文 时间:
2014-07-06 13:32:49
阅读次数:
204
把一个排好序的vector转换为一颗二分查找树。很简单的题目,递归即可,保证边界不要出错。 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; ...
分类:
其他好文 时间:
2014-07-06 12:53:50
阅读次数:
174
题目:
* 将 电话号码 one two 。。。nine zero 翻译成1 2 。。9 0
*
* 中间会有double
*
* 例如
* 输入:OneTwoThree
* 输出:123
* 输入:OneTwoDoubleTwo
* 输出:1222
* 输入:1Two2
* 输出:ERRO...
分类:
其他好文 时间:
2014-07-06 09:24:44
阅读次数:
229
;; Fermat's Little Theorem:
;; If N is a prime number and A is any positive integer less
;; than N, then A raised to the N-th power is congruent to A modulo N
;; Two numbers are said to be congruent...
分类:
其他好文 时间:
2014-07-06 09:05:22
阅读次数:
158
Power Strings
Time Limit: 3000MS
Memory Limit: 65536K
Total Submissions: 31093
Accepted: 12974
Description
Given two strings a and b we define a*b to be their concate...
分类:
其他好文 时间:
2014-07-06 00:33:22
阅读次数:
253
Given two integers n and k, return all possible combinations of k numbers out of 1 ...n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4...
分类:
其他好文 时间:
2014-07-05 22:10:53
阅读次数:
226
Description: Given two strings, write a method to decide if one is a permutation of the other.We could use the same idea from CTCI 1.1. The only diffe...
分类:
其他好文 时间:
2014-07-05 21:43:01
阅读次数:
231