Palindrome Partitioning II
摘要:这道题竟然被我做出来了,不过还是参考别人的,附代码,其中result[i]的意思是从i元素到最后需要的最小切割个数。哈哈class Solution {public: typedef vector> Sdata; int minCut(string s) { int len = s...
阅读全文
posted @
2015-04-18 17:24
xgcode
阅读(113)
推荐(0)
libevent源代码之最小堆的实现
摘要:libevent源代码之最小堆的实现libevent 中通过结构体min_heap_t实现最小堆,该结构体的声明如下:typedef struct min_heap{ struct event** p; unsigned n, a;} min_heap_t;其中p是指向指针的指针,p指向了一个数组,...
阅读全文
posted @
2015-04-18 16:14
xgcode
阅读(163)
推荐(0)
Palindrome Partitioning
摘要:这道题采用动态规划的思想。参考了别人的做法。其中二位数组buf代表字符串中任意一段是否是回文,比如字符串aba,buf[1][1]代表字符串b是不是回文,buf[0][1]代表字符串ab是不是回文,所以题目的关键是求解这个二维数组class Solution{public: vector> resu...
阅读全文
posted @
2015-04-05 17:24
xgcode
阅读(138)
推荐(0)
关于c++的效率
摘要:最近读书,感觉c++中有两点比较影响效率1、是临时对象的构造和析构。为了避免临时对象的产生,c++的编译器做了很多的优化。比如对象的构造函数的初始化列表,还有nrv优化,2、 class tclass3、 {4、 public:5、 tclass():temp("")6、 {7、 8、 }9、 1...
阅读全文
posted @
2015-04-03 00:09
xgcode
阅读(562)
推荐(0)