原题:
Given inorder and postorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
思路:和上一题一样,后续我们可以通过最后一个值得到根的值,同样可以通过定位根的值得到左右子树的...
分类:
其他好文 时间:
2014-08-21 17:22:24
阅读次数:
138
Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.用map记录出现的string的下标,避免了再次遍历。class Solu...
分类:
其他好文 时间:
2014-08-21 16:55:04
阅读次数:
177
描述:实现1 -- 求所有可能的值,O(N^2),超时了(因为超时没有跑所有的测试用例,所以不确定还有没有其他问题)代码: 1 def maxArea(self, height): 2 tmp = len(height) 3 if tmp == 0 or tm...
分类:
其他好文 时间:
2014-08-21 16:30:54
阅读次数:
213
类的成员变量在Python里描述数据结构是使用类成员变量的方式,从上面的例子可以看到这样描述:self.wndClass = WNDCLASSEX()这行代码是写在类的构造函数里,通过使用类自身对象self来给类添加成员变量wndClass 。由于在Python语言里没有声明,每增加一个类成员变量,就是通过赋值的方式产生。不过,要注意的是Python语言里的成员变量是可以动态添加的,不但可以在构造...
分类:
其他好文 时间:
2014-08-21 13:21:54
阅读次数:
197
#coding=gbkfromPyQt4importQtGui,QtCoreimportrandomclassMyWidget(QtGui.QWidget):def__init__(self,parent=None):ifparentisNone:self.app=QtGui.QApplicatio...
分类:
其他好文 时间:
2014-08-21 11:23:43
阅读次数:
220
答: init中调用super的init方法来初始化自己所包含有的父类信息1.内存分配 内存应该在[Class alloc]的时候就已经分配了,大小和类型应该由对应的Class来决定。而init方法只是进行对象内部各种变量的初始化,同时将retain count加一,表示目前这块内存空间有人在...
分类:
其他好文 时间:
2014-08-21 11:21:44
阅读次数:
167
fromPyQt4importQtGui,QtCoreclassTest(QtGui.QWidget):def__init__(self,items,parent=None):self.app=QtGui.QApplication([])super(Test,self).__init__(paren...
分类:
其他好文 时间:
2014-08-21 11:12:03
阅读次数:
214
在iOS中有几种方法来解决多线程访问同一个内存地址的互斥同步问题:方法一,@synchronized(id anObject),(最简单的方法)会自动对参数对象加锁,保证临界区内的代码线程安全[cpp]view plaincopyprint?@synchronized(self){//这段代码对其他...
分类:
移动开发 时间:
2014-08-21 11:11:33
阅读次数:
231
一、UINavigationItem1>获得方式self.navigationItem2>作用可以用来设置当前控制器顶部导航栏的内容self.navigationItem.titleself.navigationItem.titleView二、UIBarButtonItem1>用在什么地方:设置导航...
分类:
其他好文 时间:
2014-08-21 00:07:03
阅读次数:
154
今天在网上看到一个简单的todo应用,使用angularJs做前端数据绑定,利用localStorage来存储数据,觉得挺有意思的。 Angular Todo Note App Add {{note}} ng-app声明了使用todoApp作为model...
分类:
Web程序 时间:
2014-08-20 23:55:13
阅读次数:
272