`
文章列表
57 Insert Interval /** * Definition for an interval. * struct Interval { * int start; * int end; * Interval() : start(0), end(0) {} * Interval(int s, int e) : start(s), end(e) {} * }; */ bool overlap(const Interval &left,const Interval &right){ retu ...
68 Text Justification class Solution { public: vector<string> fullJustify(vector<string> &words, int L) { if(words.empty()){ return words; } if(L==0){ return words; } const int N = words.size(); ...
  class Solution { public: Solution(){} int maxProfit(int K, vector<int> &prices) { vector<int> lowVec; vector<int > highVec; if(prices.size() <=1){ return 0; } prices.erase(std::unique(prices.begin(), ...
这个是图像中的填充技术,即选择一个种子,然后对其周边联通的的依次填充。 代码未必最快,但很容易理解。 算法复杂度O(M*N) 空间复杂度O(M*N),最坏情况。 算法说明: <1>初始化 访问标记 <2>对每一个没有访问的cell,进行填充算法   填充算法:(使用栈) <1>设置初始种子,入栈 <2>如果栈空,结束 <3>出栈 依次对周围连通的cell,且没有被填充过,入栈 转2。   class Solution { public: int numIslands(vector<vec ...
zookeeper-3.4.6/docs/recipes.html Leader Election A simple way of doing leader election with ZooKeeper is to use the SEQUENCE|EPHEMERAL flags when creating znodes that represent "proposals" of clients. The idea is to have a znode, say "/election", such that each znode creates a ...
真恶心,看到本人写的,在一些恶心的网站上展示出来,真恶心,为啥那些网站还被搜索引擎收录! C语言的奇淫怪巧 更详细的说明,请参考下面文档 cpluscplus 写道 http://www.cplusplus.com/reference/cstdio/printf   问题1,输出一个字符串,但最多只输出5个 (比如向mysql中插入字符串,显然有个最大长度限制) 问题2,输出一个字符串,但该字符串占100个位置,如果不足,输出空格(即左对齐,右对齐) 问题3,输出一个字符串,只输出其前5个,并且占100个位置   这些其实在printf格式中,都有,非常强大的prin ...
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 404 100 284 100 120 9775 4130 --:--:-- --:--:-- --:--:-- 10142 100 409 100 289 100 120 9540 3961 --:--:-- --:- ...
http://dev.mysql.com/doc/refman/5.5/en/example-auto-increment.html 写道  可以使用 LAST_INSERT_ID()SQL函数或者mysql_insert_id() C API 函数来获得最新插入的ID,这获取的ID是当前connection内的变量,即不会与其他连接插
package srm646; import java.util.Comparator; import java.util.HashSet; import java.util.PriorityQueue; import java.util.Set; public class TheGridDivTwo { //<1>state的比较函数,是"大于>"即大的在前面,属于降序排序 //<2>比较函数在 score-step,这个是启发是搜索策略,可以让搜索,尽量向右搜索,而不是向左,即有一定的方向性。 //当然,如 ...
本来是想在网上搜索下现成的,结果看到一堆想吐的,尼玛啊,什么递归了,什么回溯了。无语!难道就不能负责任点,搜索下相关算法,然后,好好的实现下?又不是有多难的算法!最可恶的是,这些人还zhuangbility,以为自己写的算法很好,贴出来炫耀,有啥可炫耀的? 数学简单道理 N! <<<< N^N 我把它看成N进制,全部生成一遍,去掉位数有重复的,必然是N!这样的排列算法都比哪些瞎写的好 C(N,K> <<< N^K,同样用N进制,一共K位,那样全生成一遍,去掉不合理的(如必须是升序,或者降序),自然是对的。就这个最浅显的算法,也比这些zh ...
今天,系统日志里显示 Too many open files,于是使用lsof命令查看文件句柄数。发现是网络连接太多(CLOSE_WAIT).   linux平台下:使用下面命令 lsof -nl|grep CLOSE_WAIT|awk '{print $9,$10}'|wc -l 发现 CLOSE_WAIT|太多 展示片段如下: 192.168.10.32:52727->192.168.10.31:webcache (CLOSE_WAIT) 192.168.10.32:52747->192.168.10.31:webcache (CLOSE_WAIT)     ...
问题:Wordpress加载太慢了, 于是搜索问题原因;(BTW,我完全不会PHP,不会直接看代码就能窥天),找到如下解决办法: 参考: 知更鸟写道 禁止WordPress后台加载谷歌字体 http://zmingcx.com/wordpress-fonts-googleapis.html     我是使用chrome浏览器查看我的主页 这个文件中 wp-content/themes/twentyfourteen/functions.php 有 if ( 'off' !== _x( 'on', 'Lato font: on or off', 't ...
没搞过php,真头痛 《1》通过yum装的, yum -y install httpd 《2》不要乱修改配置文件(如LoadModule,AddType 什么的,根本不需要) /etc/httpd/conf/httpd.conf   在/etc/httpd/conf/httpd.conf中,会加载其他conf文件 Include conf.d/*.conf 而应该在这里增加文件 /etc/httpd/conf.d/php.conf 【】网上一堆说直接修改该文件,随着时间的推移,这些资料都老了,这以后安装其他东西,也务必要小心,尤其是网上资料,很多都不说os、不说版本。 p ...
错误1: ./configure时遇到错误 xml-config,libxml2 can not be found 记得装了libxml2,于是索性重装(应该是没有装libxml2-devel) yum -y install libxml2-devel libxml2-static   再次configure,通过     错误2: ext/opcache/ZendAccelerator.lo' is not a valid libtool object 这是因为,我写成了make & make isntall! [root@centos1 opt]# his ...
 tomcat 版本:8.0.15, connector和executor区别。 网上很多混淆了,异步servlet和非阻塞connector,一个是Executor,一个是connector,两者的工作阶段不同。   connector: 这个是指,外部IP连接到服务器,好比抢票软件在抢12306的火车票,因此一坨一坨的连接到12306。因此,会有很多connection(连接),建立、维护、管理这些连接,这就是connector要做的事情。显然这是web服务器性能的重要指标。即,可支持的每秒最大连接数。 connector,可以采用,blocking I/O,nio,ajp,a ...
Global site tag (gtag.js) - Google Analytics