思路:
刚开始试着把所有小于x的结点依次插到前面去,但是因为第一个和最后结点的问题真的把我搞得焦头烂额,后来想想,用我媳妇想到的方法可能更清晰一点,用两个链表分别连接小于和大于等于x 的结点,然后再把两个结点链接到一起,就可以了。在实施的时候稍微偷点懒,首先创建两个头节点,哎,现在终于明白头节点的巨大作用了,其实,按我的那个思路,先搞个头节点,然后再用两个引用pre和cur就可以轻松搞定本题了。
做完本题感觉收获好大,头节点的出现真的让我可以很轻松地搞定许多前面我费了好大的劲才搞定的题目,尤其是涉及到在链...
分类:
其他好文 时间:
2015-02-05 23:32:42
阅读次数:
357
kafka是用scala编写,用zookeeper做协调。scala的代码没学习过,这边主要看别人写的文档和自己的工作实践来的。笔记可能会写多篇,因为这东西要经常看啊,不看过了多久就忘了。
东西看完了就要问问自己3W1H
What:kafka是一个分布式(多broker,zookeeper)的,分区的(partition),消息复制的(replicate)的消息中间件(log service)...
分类:
其他好文 时间:
2015-02-05 18:32:14
阅读次数:
211
Cheapest Palindrome
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 6186
Accepted: 3014
Description
Keeping track of all the cows can be a tricky task so F...
分类:
其他好文 时间:
2015-02-05 18:24:56
阅读次数:
146
谈谈对CAP定理的理解
CAP定理的常规解释是任何分布式系统只能在一致性(Consitency),可用性(Availability)和分区容忍性(Partition Tolerance)中三选二。这个解释很让人费解,笔者在看了一些文章后谈谈我对它的理解,还请斧正。
从问题出发
假设我们用一台服务器A对外提供存储服务,为了避免这台服务器宕机导致服务不可用,我们又在另外一台服务器B上运行...
分类:
其他好文 时间:
2015-02-04 23:31:04
阅读次数:
548
Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinki...
分类:
其他好文 时间:
2015-02-04 23:17:55
阅读次数:
162
https://oj.leetcode.com/problems/partition-list/Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater...
分类:
其他好文 时间:
2015-02-04 23:12:58
阅读次数:
201
原理快速排序(Quicksort)是对冒泡排序的一种改进。从数列中挑出一个元素,称为"基准"(pivot);排序数列,所有元素比基准值小的摆放在基准前面,所有元素比基准值大的摆在基准的后面(相同的数可以到任一边)。在本次排序退出之后,该基准就处于数列的中间位置。这个称为分区(partition)操作...
分类:
编程语言 时间:
2015-02-04 16:26:31
阅读次数:
165
Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs...
分类:
其他好文 时间:
2015-02-04 12:36:35
阅读次数:
104
Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ...
分类:
其他好文 时间:
2015-02-04 07:05:10
阅读次数:
215
Given a string s, partition s such that every substring of the partition is a palindrome.
Return the minimum cuts needed for a palindrome partitioning of s.
For example, given s = "aab",
Retu...
分类:
其他好文 时间:
2015-02-03 21:27:35
阅读次数:
196