- 博客(45)
- 资源 (2)
- 收藏
- 关注
原创 翻转链表
package com.lifeibigdata.algorithms.leetcode;/** * Created by lifei on 16/6/30. */public class ReverseListNode { pu...
2016-06-30 00:00:00 67
原创 21. Merge Two Sorted Lists
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(in...
2016-06-30 00:00:00 57
原创 19. Remove Nth Node From End of List
Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the linked list becomes...
2016-06-30 00:00:00 47
原创 20. Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The ...
2016-06-30 00:00:00 49
原创 22. Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given ...
2016-06-30 00:00:00 52
原创 23. Merge k Sorted Lists
package com.lifeibigdata.algorithms.leetcode;import java.util.ArrayList;import java.util.List;/** * Created by lifei on...
2016-06-30 00:00:00 51
原创 Akka
https://github.com/lifei128/MapReduceApplication介绍:http://www.gtan.com/akka_doc/intro/what-is-akka.html案例再实战:http://www.t...
2016-06-30 00:00:00 70
原创 Callable、Future和FutureTask
创建线程的2种方式,一种是直接继承Thread,另外一种就是实现Runnable接口。这2种方式都有一个缺陷就是:在执行完任务之后无法获取执行结果。自从Java 1.5开始,就提供了Callable和Future,通过它们可以在任务执行完毕之后得...
2016-06-30 00:00:00 52
原创 24. Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should r...
2016-06-30 00:00:00 55
原创 25. Reverse Nodes in k-Group
/** * * 1 转化为两两合并 */public class ReverseKGroup { public static void main(String[] args) { ListNode l1 = new ...
2016-06-30 00:00:00 45
原创 12. Integer to Roman
http://blog.csdn.net/ljiabin/article/details/39968583
2016-06-29 00:00:00 55
原创 14. Longest Common Prefix
最简单的方式每次取一个字符,依次判断是否符合,每一个字符串实际上可以做优化,优先注意临界值,取最短字符串的长度,这种思路更清晰public String longestCommonPrefix(String[] strs) { ...
2016-06-29 00:00:00 77
原创 16. 3Sum Closest
和 3Sum 很像,与之不同的是,不再是求三个数的和是不是为0,而是看三个数的和与target的差是否为最小,只需记录当前最优解并不断更新其值就可For example, given array S = {-1 2 1 -4}, and targ...
2016-06-29 00:00:00 37
原创 判断二叉树是否对称
http://blog.csdn.net/spch2008/article/details/9365281http://blog.csdn.net/wongson/article/details/45251861public class IsM...
2016-06-29 00:00:00 66
原创 15. 3Sum
简单的做法,根据2Sum,遍历3次,此时时间复杂度是O(n的3次方)import java.util.ArrayList;import java.util.Arrays;import java.util.List;/** * Crea...
2016-06-29 00:00:00 212
原创 7. Reverse Integer
public class ReverseInteger { public static void main(String[] args) { ReverseInteger ri = new ReverseInteger();...
2016-06-28 00:00:00 52
原创 10. Regular Expression Matching
/** * Created by lifei on 16/5/28. * * 枚举一般都不好使 */public class RegularExpressionMatching { public static void main...
2016-06-28 00:00:00 43
原创 11. Container With Most Water
就是说,x轴上在1,2,...,n点上有许多垂直的线段,长度依次是a1, a2, ..., an。找出两条线段,使他们和x抽围成的面积最大。面积公式是 Min(ai, aj) X |j - i| 最简单的做法,for循环两次,时间复杂度是O...
2016-06-28 00:00:00 54
原创 9. Palindrome Number
/** * Created by lifei on 16/6/28. * * 从两头依次取数字比较,向中间推进。 */public class IsPalindrome { public static void main(Str...
2016-06-28 00:00:00 49
原创 6. ZigZag Conversion
PAYPALISHIRING P A H NA P L S I I GY I Rimport java.util.Arrays;/** * * * convert("PAYPALISHIRING", 3)...
2016-06-28 00:00:00 102
原创 4. Median of Two Sorted Arrays
https://my.oschina.net/datacube/blog/759256
2016-06-27 00:00:00 36
原创 3. Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the ...
2016-06-27 00:00:00 58
原创 1. Two Sum
Given nums = [2, 7, 11, 15], target = 9,Because nums[0] + nums[1] = 2 + 7 = 9,return [0, 1].package com.lifeibigdata.alg...
2016-06-27 00:00:00 46
原创 2. Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of ...
2016-06-27 00:00:00 62
原创 5. Longest Palindromic Substring
/** * * 最长回文子串 * * 著名的Manacher算法O(N)时间O(N)空间 */public class LongestPalindrome { public static void main(String[] a...
2016-06-27 00:00:00 38
原创 字符串
字符串循环移位(时空复杂度尽量低)字符串的最优无损压缩(Huffman编码/前缀编码、Huffman树:逻辑结构/存储结构)LCS最长公共子序列字符串的全排列(递归、非递归,全排列的用途)KMP(手写next数组、KMP的原理、思维方式、代...
2016-06-26 00:00:00 69
原创 supervise安装
安装http://cr.yp.to/daemontools/install.html报错找不到/lib64/libc.so.6这个库文件在src/conf-cc第一行的数据,增加 -include /usr/include/errno.h ...
2016-06-24 00:00:00 309
原创 jvm GC专家 2
我们先回顾一下主流Java的垃圾回收器(HotSpot JVM)。本文是针对堆的垃圾回收展开讨论的。堆被分解为较小的三个部分。具体分为:新生代、老年代、持久代。绝大部分新生成的对象都放在Eden区,当Eden区将满,JVM会因申请不到内存,而...
2016-06-23 00:00:00 76
原创 CMS
总体介绍:CMS(Concurrent Mark-Sweep)是以牺牲吞吐量为代价来获得最短回收停顿时间的垃圾回收器。对于要求服务器响应速度的应用上,这种垃圾回收器非常适合。在启动JVM参数加上-XX:+UseConcMarkSweepGC ,这...
2016-06-23 00:00:00 171
原创 G1
介绍:Garbage First(G1)致力于在多CPU和大内存服务器上对垃圾收集提供软实时目标(soft real-time goal )和高吞吐量(high throughput )。从JDK 6u14开始就已经在Hotspot上试验,到现在的...
2016-06-23 00:00:00 91
原创 jvm GC专家 1
在学习GC之前,你首先应该记住一个单词:“stop-the-world”。Stop-the-world会在任何一种GC算法中发生。Stop-the-world意味着 JVM 因为要执行GC而停止了应用程序的执行。当Stop-the-world发生时,除了GC所需的线程以外,所有线程都处于等待状...
2016-06-22 22:20:00 117
原创 左旋转字符串
public class LeftRotateString { /** * Q 26 左旋转字符串 * 题目:定义字符串的左旋转操作:把字符串前面的若干个字符移动到字符串的尾部。 * 如把字符串abcdef左旋转...
2016-06-22 00:00:00 48
原创 java 值传递 数组传递
public class Test { String str = new String("good"); char[] ch = {'a','b','c'}; int i = 10; public void cha...
2016-06-22 00:00:00 125
原创 求树的直径
package com.lifeibigdata.algorithms.blog;import java.util.ArrayList;import java.util.List;/** * Created by lifei on 16/...
2016-06-22 00:00:00 101
原创 用两个栈实现队列&&用两个队列实现一个栈
import java.util.ArrayList;import java.util.List;import java.util.Stack; /* * Q 57 用两个栈实现队列 */public...
2016-06-22 00:00:00 73
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人