Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask before coding. Bonus poi...
分类:
其他好文 时间:
2015-03-18 16:02:37
阅读次数:
120
Made a stupid bug....... When reverse the vector, stop it at mid. Otherwise, it will swap back......Mark!!!!!!!! 1 /** 2 * Definition for binary tree....
分类:
其他好文 时间:
2015-03-18 10:23:29
阅读次数:
120
Still 3 methods:Same with inorder, but post order is a little different. We need to treat it as reverse result of preorder.So we go to right branch fi...
分类:
其他好文 时间:
2015-03-18 08:57:58
阅读次数:
132
This question is almost same as the previous one.I just use a stack (another vector) of vector to store the level result. Then reverse it. 1 /** 2 * ....
分类:
其他好文 时间:
2015-03-18 08:56:41
阅读次数:
155
Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express...
分类:
其他好文 时间:
2015-03-18 01:09:26
阅读次数:
160
Evaluate the value of an arithmetic expression in Reverse Polish Notation.
Valid operators are +, -, *, /. Each operand may be an integer or another expression.
Some examples:
[“2...
分类:
其他好文 时间:
2015-03-17 21:56:20
阅读次数:
160
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ...
分类:
其他好文 时间:
2015-03-17 21:45:00
阅读次数:
103
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ...
分类:
其他好文 时间:
2015-03-17 19:27:15
阅读次数:
111
problem:
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
thinking:
(1)整型反转直观很容易理解。如正负,尾数为0等问题还好处理。
(2)反转溢出问题要仔细处理。
code:
class Solution {
public:
...
分类:
其他好文 时间:
2015-03-17 18:04:05
阅读次数:
132
题目:输入一个英文句子,翻转句子中单词的顺序,但单词内字符的顺序不变。句子中单词以空格符隔开。为简单起见,标点符号和普通字母一样处理。例如输入“I am a student.”,则输出“student. a am I”。 分析:先颠倒句子中的所有字符,再颠倒每个单词内的字符。由于单词内的字符被翻转两次,因此顺序仍然和输入时的顺序保持一致。
void Reverse(char *pBegi...
分类:
其他好文 时间:
2015-03-17 14:19:07
阅读次数:
177