这道题稍微有点意思,知道答案发现,呀,这么简单就能做啊。我一开始想的是,相遇之后用另一个指针怎么走,然后满足什么关系之后能推出来,其实不用这么麻烦。是很简单的数学关系,我画个图说一下。
S1代表的是链表进入环之前的长度,a代表当两个指针相遇时,走一步的指针在环里走的长度,S2代表的是环的周长,那么根据条件,相遇时,走两步的指针走的距离是走一步的两倍,我们得到公式:
(S1+a)*2 =...
分类:
其他好文 时间:
2014-05-10 10:29:57
阅读次数:
364
/* 内存管理原则: 1.谁alloc,new或copy,谁就进行一次release
2.谁retain,谁release */#import @interface Person : NSObject { Car * _car; int
_age;}- (void)setCar:(Car *)car...
分类:
其他好文 时间:
2014-05-08 10:18:57
阅读次数:
284
言简意赅A single instruction enters the CPU at the
Fetch stage and the PC is incremented in one clock cycle. In the next clock
cycle, the instruction move...
分类:
其他好文 时间:
2014-05-07 11:23:20
阅读次数:
417
nginx的slab分配器主要和共享内存(nginx自己实现的共享内存 采用mmap或者shm实现)一起使用,Nginx在解析完配置文件,把即将使用的共享内存全部以list链表的形式,对共享内存进行管理和划分。在nginx_cycle.c中
static ngx_int_t
ngx_init_zone_pool(ngx_cycle_t *cycle, ngx_shm_zone_t *zn)
{
...
分类:
其他好文 时间:
2014-05-07 08:18:53
阅读次数:
361
1.屏幕分辨率是指屏幕可显示的最高像素数目。
2.屏幕尺寸显而易见,是指其面积。
3.另外还有一个术语叫“点距”,就是屏幕上像素与像素之间的距离,也就是代表单位面积内像素点数目的一个值
屏幕尺寸和点距都一定时,屏幕的分辨率才一定。当两项中有一项发生变化,那么分辨率就会发生变化。
4.在ios开发中,我们的非retain屏,就用原来像素。比如说分辨率为:320*480,那么它的屏...
分类:
其他好文 时间:
2014-05-07 06:16:44
阅读次数:
243
Playback control of audio/video files and streams is managed as a state machine. The following diagram shows the life cycle and the states of a MediaPlayer object driven by the supported playback cont...
分类:
移动开发 时间:
2014-05-03 21:36:21
阅读次数:
568
原题地址:http://oj.leetcode.com/problems/linked-list-cycle/题意:判断链表中是否存在环路。解题思路:快慢指针技巧,slow指针和fast指针开始同时指向头结点head,fast每次走两步,slow每次走一步。如果链表不存在环,那么fast或者fast...
分类:
编程语言 时间:
2014-05-01 10:33:38
阅读次数:
426
原题地址:http://oj.leetcode.com/problems/linked-list-cycle-ii/题意:如果链表中存在环路,找到环路的起点节点。解题思路:这道题有点意思。首先使用快慢指针技巧,如果fast指针和slow指针相遇,则说明链表存在环路。具体技巧参见上一篇http://w...
分类:
编程语言 时间:
2014-05-01 08:19:31
阅读次数:
340
IIUPC2006Problem G: Going in Cycle!!Input:
standard inputOutput: standard outputYou are given a weighted directed graph
withnvertices andmedges. Each ...
分类:
其他好文 时间:
2014-05-01 04:32:53
阅读次数:
271
1、
??
Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…
You must do this in-place without altering the nodes' values.
For example,
Given {1,2...
分类:
其他好文 时间:
2014-04-29 13:16:21
阅读次数:
250