
M
xudli
这个作者很懒,什么都没留下…
展开
-
M1: 复制带随机指针的链表
一个链表问题:复制带随机指针的链表 题目:有一个链表L,其每个节点有2个指针,一个指针next指向链表的下个节点,另一个random随机指向链表中的任一个节点,可能是自己或者为空,写一个程序,要求复制这个链表的结构并分析其复杂性 解决方法一: O(n)的复杂度,扫面两边即可。 图【1】 图【1】是需要复制的链表 图【2】 如图【2】所示,ABCD是原来的链表,A’B’转载 2013-03-07 13:49:01 · 1076 阅读 · 0 评论 -
Consider N coins aligned in a row.
Consider N coins aligned in a row. Each coin is showing either heads or tails. The adjacency of these coins is the number of adjacent pairs of coins with the same side facing up. It must return the原创 2014-11-05 09:56:45 · 12463 阅读 · 0 评论