Sort a linked list in O(n log n)
time using constant space complexity.
算法一 自顶向下折半归并,递归
使用递归。进行折半。
先使用快慢指针,找到中间结点。将链表一分为二。
对此两链表进行递归排序后,进行归并。
在leetcode上实际执行时间为62ms。
/**
* Definition for...
分类:
其他好文 时间:
2015-06-08 09:57:20
阅读次数:
118
Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.For exampl...
分类:
其他好文 时间:
2015-06-07 23:12:44
阅读次数:
153
1 题目:Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindrome...
分类:
其他好文 时间:
2015-06-07 21:34:42
阅读次数:
123
Sort a linked list inO(nlogn) time using constant space complexity.链表排序,要求时间复杂度O(nlgn),我写的归并排序。/** * Definition for singly-linked list. * public class...
分类:
其他好文 时间:
2015-06-07 17:18:21
阅读次数:
131
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 defined...
分类:
其他好文 时间:
2015-06-07 15:49:48
阅读次数:
105
1.为什么要设置JVM内存大小呢?
因为如果你的程序运行时超过JVM默认内存大小,就不会报传说中内存溢出异常。
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at junit.Bean.main(Bean.java:25)
2.在MyEclipse 菜单 Run->run conf...
分类:
系统相关 时间:
2015-06-06 23:33:39
阅读次数:
233
Length of Last WordTotal Accepted: 47690 Total Submissions: 168587Given a string s consists of upper/lower-case alphabets and empty space characters '...
分类:
编程语言 时间:
2015-06-06 16:36:34
阅读次数:
131
**1,eclipse开发出的j2ee程序,发布到Tomcat的Webapps目录下:将eclipse下配置的tomcat server 移除所有程序,然后,右键--open,改 server location2,eclipse发布程序到webapps下后,以tomcat的startup.bat启动...
分类:
其他好文 时间:
2015-06-06 14:47:10
阅读次数:
75
题目描述
To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For...
分类:
其他好文 时间:
2015-06-06 10:37:31
阅读次数:
169
题目:Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes?...
分类:
其他好文 时间:
2015-06-06 10:27:42
阅读次数:
102