Divide two integers without using
multiplication, division and mod operator. 1 class Solution { 2 public: 3 int
divide(int dividend, int divisor) ...
分类:
其他好文 时间:
2014-06-06 17:40:07
阅读次数:
193
水题。描写叙述的还挺麻烦的,实际上就是纸老虎,用两个string,一个存上一轮的结果,一个用来更新出这一轮的结果,每次扫描上一轮,统计一个字符出现的次数,然后把这个次数和字符增加到这一轮的字符串中就能够了。class
Solution {public: string countAndSay(i...
分类:
其他好文 时间:
2014-06-05 18:34:43
阅读次数:
204
Given two binary strings, return their sum
(also a binary string).For example,a ="11"b ="1"Return"100".public class
Solution { /**The program is us...
分类:
其他好文 时间:
2014-06-05 14:08:35
阅读次数:
188
Follow up for problem "Populating Next Right
Pointers in Each Node".What if the given tree could be any binary tree? Would
your previous solution stil...
分类:
其他好文 时间:
2014-06-05 13:26:37
阅读次数:
335
class Solution {public: ListNode
*swapPairs(ListNode *head) { ListNode *a = NULL; ListNode *b = NULL; ListNode
*tail = NULL; ...
分类:
其他好文 时间:
2014-06-05 12:55:24
阅读次数:
216
Givennpoints on a 2D plane, find the maximum
number of points that lie on the same straight line.public class Solution { /**
* This program is used t....
分类:
其他好文 时间:
2014-06-03 17:05:21
阅读次数:
434
在Visual Studio 中,当你在所有打开的文件中进行切换时,在Solution
Explorer中也会自动定位到这个文件的目录下面,这个功能用来查找当前文件是非常有用。在Tools->Options中,有个Trace Active
Item in Solution Exploer,把那个勾勾...
分类:
其他好文 时间:
2014-06-03 15:27:57
阅读次数:
329
【题目】
Two elements of a binary search tree (BST) are swapped by mistake.
Recover the tree without changing its structure.
Note:
A solution using O(n) space is pretty straight forward. Could you devise a constant space solution?
confused what "{1,#,2,3}" ...
分类:
其他好文 时间:
2014-06-02 10:38:17
阅读次数:
246
问题:
Write a program to solve a Sudoku puzzle by filling the empty cells.
Empty cells are indicated by the character '.'.
You may assume that there will be only one unique solution.
...
分类:
其他好文 时间:
2014-06-02 05:25:23
阅读次数:
295
class Solution {
public:
void swap(int &a,int &b)
{
int t=a;
a=b;
b=t;
}
void ksort(int l,int h,int a[])
{
if(h<l+2)
return;
int e=h,p=l;
while(...
分类:
其他好文 时间:
2014-06-02 03:01:26
阅读次数:
206