Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?摘自剑指offer:当用一个指针遍历链表不能解决问题的时候,可以尝试用两个指针来遍...
分类:
其他好文 时间:
2015-04-17 00:56:38
阅读次数:
166
关于nginx的内存使用,我们先看代码,下面是nginx_cycle.c中对全局数据结构cycle的初始化过程 pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log); //申请16K的内存池 if (pool == NULL) { ...
分类:
其他好文 时间:
2015-04-15 11:01:05
阅读次数:
125
331down voteacceptedSee it inActivity Lifecycle(at Android Developers).onCreate():Called when the activity is first created. This is where you should ...
分类:
移动开发 时间:
2015-04-13 16:38:35
阅读次数:
385
题意:给出n个点m条边的加权有向图,求平均值最小的回路自己想的是用DFS找环(真是too young),在比较找到各个环的平均权值,可是代码实现不了,觉得又不太对后来看书= =好巧妙的办法, 使用二分法求解,首先记录下来这m条边的最大权值ub然后可以猜测一个mid,只需要判断是否存在平均值小于mid...
分类:
其他好文 时间:
2015-04-11 14:30:56
阅读次数:
115
题目描述:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra spac...
分类:
其他好文 时间:
2015-04-10 19:52:27
阅读次数:
106
写了无数次,今天终于自己想明白了,但是好像还是记住后明白的plotting tool:http://flowchart.com/public class Solution { public ListNode detectCycle(ListNode head) { if(head...
分类:
其他好文 时间:
2015-04-09 06:27:21
阅读次数:
120
解决办法是忽略掉关联类型的数据,使用jsonConfig进行配置,代码如下: JsonConfig jsonConfig = new JsonConfig(); //建立配置文件 jsonConfig.setIgnoreDefaultExcludes(false); //设置默认忽略 jsonCon...
分类:
Web程序 时间:
2015-04-08 23:00:41
阅读次数:
163
Given a linked list, determine if it has a cycle in it.Can you solve it without using extra space?每个节点再开辟一个属性存放是否访问过,这样遍历一遍即可知道是否有环。但为了不增加额外的空间,可以设置两个...
分类:
其他好文 时间:
2015-04-08 01:01:24
阅读次数:
120
给定一个链表,判断是否存在环 思路:龟兔赛跑,一个指针兔跑得快,一个指针龟跑得慢,如果有环兔子一定会遇到乌龟(fast == slow),如果没有环兔子一定能到达终点(fast == null) class Solution {public: bool hasCycle(ListNode *head...
分类:
其他好文 时间:
2015-04-07 15:05:44
阅读次数:
104