这道题稍微有点意思,知道答案发现,呀,这么简单就能做啊。我一开始想的是,相遇之后用另一个指针怎么走,然后满足什么关系之后能推出来,其实不用这么麻烦。是很简单的数学关系,我画个图说一下。
S1代表的是链表进入环之前的长度,a代表当两个指针相遇时,走一步的指针在环里走的长度,S2代表的是环的周长,那么根据条件,相遇时,走两步的指针走的距离是走一步的两倍,我们得到公式:
(S1+a)*2 =...
分类:
其他好文 时间:
2014-05-10 10:29:57
阅读次数:
364
http://acm.fzu.edu.cn/problem.php?pid=2171 Problem
2171 防守阵地 II Accept: 73Submit: 256Time Limit: 3000 mSecMemory Limit :...
分类:
其他好文 时间:
2014-05-07 18:41:12
阅读次数:
440
这道题还挺复杂的,回来看了好一会儿才想起当时怎么想的。。上道题刚说不要打表,这道题就用了打表。。
总的思路是这样的,从后面往前面打表,最后一个位置的最小分割一定是0,那往前呢,如果当前考虑的位置是start,并且substr(s, i)是回文的,那么如果已知i+1开始的分割次数,那么start这个位置的分割应该就是start原来的和i+1开始的分割次数加1之间的最小值。DP的思想,很直接。
但...
分类:
其他好文 时间:
2014-05-07 07:37:39
阅读次数:
307
一 线性表
1.1 数组
1.1.1 Remove Duplicates from Sorted Array
1.1.2 Remove Duplicates from Sorted Array II
1.1.3 Search in Rotated Sorted Array
1.1.4 Search in Rotated Sorted Array II
1.1.5 Median of...
分类:
其他好文 时间:
2014-05-07 04:24:26
阅读次数:
363
五一中间断了几天,开始继续。。。
1、
??
Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.
Return a...
分类:
其他好文 时间:
2014-05-06 18:54:59
阅读次数:
386
javascript
获取元素样式常用方法。Javascript获取CSS属性值方法:getComputedStyle和currentStyle1
.对于元素的内联CSS样式(hello),可以直接使用element.style.color来直接获取css属性的值;2. 但是对于外部定义的css样式...
分类:
编程语言 时间:
2014-05-05 10:19:39
阅读次数:
448
Given an array of non-negative integers, you
are initially positioned at the first index of the array.Each element in the
array represents your maximu...
分类:
其他好文 时间:
2014-05-05 10:05:58
阅读次数:
300
现在主流浏览器基本上实现了全屏效果,但是不同浏览器实现不一样:【进入和退出全屏】//
Webkit (works in Safari5.1 and Chrome
15)element.webkitRequestFullScreen();document.webkitCancelFullScreen(...
概念:
流程图的组成:
a. 活动 Activity / 节点 Node
b. 流转 Transition / 连线(单向箭头)
c. 事件
1.流转(Transition)
a) 一般情况一个活动中可以指定一个或多个Transition
i. 开始活动(Start)中只能有一个Transition。
ii. 结束活动(End)中没有Transitio...
分类:
其他好文 时间:
2014-05-03 20:53:19
阅读次数:
311