2015年5月12日

LeetCode-Recover Binary Search Tree

摘要: Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is ... 阅读全文

posted @ 2015-05-12 22:00 linxiong1991 阅读(103) 评论(0) 推荐(0) 编辑

LeetCode-Jump Game II

摘要: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximu... 阅读全文

posted @ 2015-05-12 10:57 linxiong1991 阅读(116) 评论(0) 推荐(0) 编辑

2015年5月10日

LeetCode-60 Permutation Sequence

摘要: The set[1,2,3,…,n]contains a total ofn! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie... 阅读全文

posted @ 2015-05-10 16:46 linxiong1991 阅读(673) 评论(0) 推荐(0) 编辑

2015年5月9日

LeetCode-79 Word Search

摘要: Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjace... 阅读全文

posted @ 2015-05-09 00:19 linxiong1991 阅读(1331) 评论(0) 推荐(0) 编辑

2015年5月7日

LeetCode-Subsets II

摘要: Given a collection of integers that might contain duplicates,nums, return all possible subsets.Note:Elements in a subset must be in non-descending ord... 阅读全文

posted @ 2015-05-07 19:47 linxiong1991 阅读(117) 评论(0) 推荐(0) 编辑

2015年5月5日

二叉树的遍历(非递归)

摘要: 1. 先序遍历public void preorder(TreeNode root) { if(root == null) return; Stack stack = new Stack(); while(true) { if(root... 阅读全文

posted @ 2015-05-05 17:37 linxiong1991 阅读(160) 评论(0) 推荐(0) 编辑

2015年4月28日

LeetCode-204 Count Primes

摘要: Count the number of prime numbers less than a non-negative number,n题意:求小于n的所有素数的个数。思路:1. 范围在1~n-1,求先把2的倍数删除,再把3的倍数删除,再把5的倍数删除。。。每次都把集合中最小元素的倍数删除,多次循环之... 阅读全文

posted @ 2015-04-28 15:22 linxiong1991 阅读(93) 评论(0) 推荐(0) 编辑

Java 集合的继承关系(简化)

摘要: 最近在看《Java编程思想》的第17章时,发现集合的继承关系中缺了Queue的类图,因此准备把图补上。另外,在绘制的过程中只保留了常用的集合对象,使整个继承看起来比较简洁。如果有错误,请大家指出。 阅读全文

posted @ 2015-04-28 11:36 linxiong1991 阅读(301) 评论(0) 推荐(0) 编辑

2015年4月25日

LeetCode-8 String to Integer (atoi)

摘要: Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below and ... 阅读全文

posted @ 2015-04-25 22:00 linxiong1991 阅读(118) 评论(0) 推荐(0) 编辑

2015年4月23日

LeetCode-166 Fraction to Recurring Decimal

摘要: Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating,... 阅读全文

posted @ 2015-04-23 12:06 linxiong1991 阅读(232) 评论(0) 推荐(0) 编辑

导航