Sort a linked list in O(n log n) time using constant space complexity.
这道题是要求对单链表进行排序,有个O(nlogn)的时间复杂度的要求。我的想法是采取类似头插法的方式,遍历链表结点,设3个指针,min指向当前链表中的最小值,max指向当前链表中的最大值,cur指向前一插入的值。
min , max , cur 初始时都指向第...
分类:
其他好文 时间:
2015-03-17 15:58:02
阅读次数:
181
1. 题目Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is defi...
分类:
其他好文 时间:
2015-03-17 15:52:52
阅读次数:
131
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.
Do not allocate extra space for another array, you must do this in place wit...
分类:
其他好文 时间:
2015-03-17 15:49:28
阅读次数:
128
zookeeper 基本概念 The ZooKeeper Data Model ZooKeeper has a hierarchal name space, much like a distributed file system. The only difference is that each node in the namespace can have data associat...
分类:
其他好文 时间:
2015-03-17 14:28:05
阅读次数:
120
编辑Ctrl + Space Basic code completion (the name of any class,method or variable)Ctrl + Shift + Space Smart code completion (filters the list of methods...
分类:
其他好文 时间:
2015-03-17 12:14:10
阅读次数:
165
space2comment.pyReplaces space character (‘ ‘) with comments ‘/**/’Example:* Input: SELECT id FROM users* Output: SELECT/**/id/**/FROM/**/usersTested ...
分类:
数据库 时间:
2015-03-17 12:11:20
阅读次数:
256
white-space的值:normal 默认。空白会被浏览器忽略。pre 空白会被浏览器保留。其行为方式类似 HTML 中的 标签。nowrap 文本不会换行,文本会在在同一行上继续,直到遇到 标签为止。pre-wrap 保留空白符序列,但是正常地进行换行。pre-line 合并空白符序列,但是....
分类:
其他好文 时间:
2015-03-17 11:51:34
阅读次数:
116
Follow up for "Unique Paths":
Now consider if some obstacles are added to the grids. How many unique paths would there be?
An obstacle and empty space is marked as 1 and 0 respectively
in the grid...
分类:
其他好文 时间:
2015-03-17 10:28:53
阅读次数:
180
题目:Sort a linked list in O(n log n) time using constant space complexity.
思路:要求时间复杂度O(nlogn)
知识点:归并排序,链表找到中点的方法
存在的缺点:边界条件多考虑!!!
/**
* LeetCode Sort List Sort a linked list in O(n log n) time us...
分类:
编程语言 时间:
2015-03-16 23:14:12
阅读次数:
260
Determine whether an integer is a palindrome. Do this without extra space.(source)判断一个数字是否为回文数,并且不使用额外的存储空间。“回文”是指正读反读都能读通的句子,那么回文数,就很容易理解,就是指一个数正反读的值是相同的。还有一个要求是不要使用额外的存储空间。Hints:
要将一个数的最高位与最低位比较,取出一...
分类:
其他好文 时间:
2015-03-16 17:45:42
阅读次数:
142