很简单的题目,在想是不是后面就不要更这么简答的了,大家都会写,没人看啊。层序遍历的基础上,加了保存每一层,加了从下往上输出,就是一个vector和一个stack的问题嘛,无他,但手熟尔。
class Solution {
public:
vector > levelOrderBottom(TreeNode *root) {
vector > res;
if...
分类:
其他好文 时间:
2014-05-08 11:17:46
阅读次数:
268
class Solution{ public: int maxArea(vector&
height) { int len = height.size(), low = 0, high = len -1 ; int maxArea = 0; ...
分类:
其他好文 时间:
2014-05-08 10:23:54
阅读次数:
287
1.动态分配的对象的析构函数 1 class man{ 2 public: 3 man(){ 4
cout<<"man begin"<<endl; 5 }; 6 ~man(){ 7 cout<<"man
end"<<endl; 8 } 9 ...
分类:
编程语言 时间:
2014-05-08 09:20:20
阅读次数:
321
#import @interface Person : NSObject{ /*
成员变量作用域有四种: 1.@public:能在程序中任何地方直接访问成员变量 2.@protect:能在当前类和子类中直接访问成员变量(默认情况下)
3.@provate:只能在当前类中直接访问成员变量(@prope...
分类:
其他好文 时间:
2014-05-08 09:14:29
阅读次数:
500
I / O流(stream)是供数据传输的通道字节流(通用的)inputStream(父类)
FileInputStreamoutputStream(父类) FileOutputStream操作流的步骤a) 产生字节流对象b) 调用读写方法c)
关闭流2. public void copyIm...
分类:
其他好文 时间:
2014-05-08 09:11:37
阅读次数:
295
一次通过: 1 public class Solution { 2 public int
romanToInt(String s) { 3 int sum = 0; 4 int[] num = new int[s.length()]; 5 if...
分类:
其他好文 时间:
2014-05-08 08:24:26
阅读次数:
233
#include
#include
using namespace std;
class CPerson
{
protected:
char *m_szName;
char *m_szId;
int m_nSex;//0:women,1:man
int m_nAge;
public:
CPerson(char *name,char *id,int sex,int age);
voi...
分类:
其他好文 时间:
2014-05-08 08:15:08
阅读次数:
250
重载操作符与转换--自增/自减操作符引言: 自增,自减操作符经常由诸如迭代器这样的类实现,这样的类提供类似于指针的行为来访问序列中的元素。例如,可以定义一个类,该类指向一个数组并为该数组中的元素提供访问检查:class CheckedPtr
{
public:
//这个类没有默认构造函数,必须提供指向数组的指针。
/**构造函数的参数是两个指针:一个指向数组的开始,另一个指向...
分类:
编程语言 时间:
2014-05-08 08:09:00
阅读次数:
493
C++里面的伪函数(函数对象)其实就是一个类重载了()运算符,这样类的对象在使用()操作符时,看起来就像一个函数调用一样,这就叫做伪函数。class
Hello{ public: void operator()() //第一个()表示操作符,第二个表示函数参数列表 ...
分类:
编程语言 时间:
2014-05-08 06:35:33
阅读次数:
280
抠细节的题目,很多次过,特别是 Integer.MIN_VALUE 与
Integer.MAX_VALUE的绝对值并不一样大 1 public class Solution { 2 public int atoi(String
str) { 3 int result=0; 4...
分类:
其他好文 时间:
2014-05-08 05:44:17
阅读次数:
343