Ch3-3: popat(int idx) of setofstack
来源:互联网 发布:电影自动采集源码 编辑:程序博客网 时间:2024/05/10 16:26
Continue to use class to design solution, also, start to use STL, such as container (vector, stack, set, ...). save time and to be more professional.
The design without popat method is similar to the one to devide a single array into 3 stacks.
But the class of setofstack with popat should be more carefully.
for example:
bool empty(){ // empty of the whole set//if(cur==0) return st[cur].empty(); // this is not working because it might have // blank substack in the middle of full stack // so need to have while condition to find the last // not-empty stack // if (cur!=-1 && st[cur].empty()) --cur; ---> // this one only find the previous stack of // empty stack, need to use while condition insteadwhile(cur!=-1 && st[cur].empty()) --cur;if (cur==-1) return true;return false;}
Full code. Still, this is modified from Hawstein's code but may not the best solution, learn from others too..
output:
Executing the program....$demo 19181716151413121110huxiaolin ...TOT
0 0
- Ch3-3: popat(int idx) of setofstack
- icvGetIdxAt( CvMat* idx, int pos )
- IDX
- idx
- Art of Multiprocessor Programming 答案 ch3
- 算法入门竞赛ch3:3-1586
- temporary of type `int'
- CH3: 列表
- DPDK-CH3
- Ch3-SingleLinkedList
- warning C4047: '=' : 'int *' differs in levels of indirection from 'int (*)[3]'
- Exchange of two int variables
- proto.c:3640: failed assertion "idx >=0 && idx < num_tree_types"
- C.for($idx = 1; $idx < STOP_AT; $idx *= 2)
- Argument of type '(Foo::)(int,int)' does not match 'void (*)(int,int)'以及静态函数问题
- 自学感想3—— 《构建之法》CH2&CH3&CH4&CH11
- 周志华《机器学习》课后习题解答系列(四):Ch3.3
- APUE-CH3 open
- LeetCode(144)Binary Tree Preorder Traversal
- 三年规划(2014-2016)
- LeetCode(102)Binary Tree Level Order Traversal
- 面向对象与面向过程
- [leet code] Set Matrix Zeroes
- Ch3-3: popat(int idx) of setofstack
- Java单例设计模式(饿汉式和懒汉式)
- LeetCode(107)Binary Tree Level Order Traversal II
- 删除重复列的SQL语句
- RandomAccessFile(随机读写流)
- 2014年展望
- go 服务器出现too many open files的错误
- 今年是本命年了
- too many open files