08 2014 档案

[leecode]Binary Tree Preorder Traversal
摘要:Binary Tree Preorder TraversalGiven a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ ... 阅读全文

posted @ 2014-08-31 17:48 喵星人与汪星人 阅读(184) 评论(0) 推荐(0) 编辑

[leetcode]Binary Tree InorderTraversal
摘要:Binary Tree Inorder TraversalGiven a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ ... 阅读全文

posted @ 2014-08-31 17:44 喵星人与汪星人 阅读(159) 评论(0) 推荐(0) 编辑

[leecode]Best Time to Buy and Sell Stock III
摘要:Best Time to Buy and Sell Stock IIISay you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the... 阅读全文

posted @ 2014-08-26 17:20 喵星人与汪星人 阅读(191) 评论(0) 推荐(0) 编辑

[leecode]Clone Graph
摘要:Clone GraphClone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes are l... 阅读全文

posted @ 2014-08-25 20:55 喵星人与汪星人 阅读(180) 评论(0) 推荐(0) 编辑

[leecode]Word Break II
摘要:Word Break IIGiven a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word.Return all... 阅读全文

posted @ 2014-08-24 22:49 喵星人与汪星人 阅读(283) 评论(0) 推荐(0) 编辑

快速排序之单项扫描法
摘要:快速排序是排序算法中最受青睐的算法之一,相对于堆排序和归并排序而言,即便具有相同的复杂度O(NlogN)。面对大数据而言,快排的效率也更高。一般而言,数据结构中的排序算法都是采取的双向指针法。在之前写的一篇博文《排序算法(初级版)之快排、归并、堆排序》中已经有过总结。这里就不再啰嗦了。本篇博文主要讲... 阅读全文

posted @ 2014-08-22 17:00 喵星人与汪星人 阅读(1785) 评论(0) 推荐(0) 编辑

[leetcode]Convert Sorted List to Binary Search Tree
摘要:Convert Sorted List to Binary Search TreeGiven a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.... 阅读全文

posted @ 2014-08-16 10:51 喵星人与汪星人 阅读(311) 评论(0) 推荐(0) 编辑

[leetcode]Minimum Path Sum
摘要:Minimum Path SumGiven amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along ... 阅读全文

posted @ 2014-08-16 00:58 喵星人与汪星人 阅读(198) 评论(0) 推荐(0) 编辑

[leetcode]Sum Root to Leaf Numbers
摘要:Sum Root to Leaf NumbersGiven a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-l... 阅读全文

posted @ 2014-08-16 00:45 喵星人与汪星人 阅读(204) 评论(0) 推荐(0) 编辑

[leetcode]Unique Binary Search Trees
摘要:Unique Binary Search TreesGivenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a to... 阅读全文

posted @ 2014-08-16 00:38 喵星人与汪星人 阅读(159) 评论(0) 推荐(0) 编辑

[leetcode]Valid Number
摘要:Valid NumberValidate if a given string is numeric.Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>trueNote:It is intended for the ... 阅读全文

posted @ 2014-08-16 00:02 喵星人与汪星人 阅读(765) 评论(0) 推荐(0) 编辑

[leetcode]Unique Binary Search Trees II
摘要:Unique Binary Search Trees IIGivenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your pr... 阅读全文

posted @ 2014-08-15 22:55 喵星人与汪星人 阅读(281) 评论(0) 推荐(0) 编辑

[leetcode]Interleaving String
摘要:Interleaving StringGivens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", r... 阅读全文

posted @ 2014-08-15 21:25 喵星人与汪星人 阅读(393) 评论(0) 推荐(0) 编辑

[leetcode]Minimum Window Substring
摘要:Minimum Window SubstringGiven a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).Fo... 阅读全文

posted @ 2014-08-15 17:04 喵星人与汪星人 阅读(316) 评论(0) 推荐(0) 编辑

[leetcode]Spiral Matrix
摘要:Spiral MatrixGiven a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[... 阅读全文

posted @ 2014-08-15 15:55 喵星人与汪星人 阅读(209) 评论(0) 推荐(0) 编辑

[leetcode]Spiral Matrix II
摘要:Spiral Matrix IIGiven an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the... 阅读全文

posted @ 2014-08-15 14:54 喵星人与汪星人 阅读(287) 评论(0) 推荐(0) 编辑

[leetcode]Rotate Image
摘要:Rotate ImageYou are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?CC上的原题,... 阅读全文

posted @ 2014-08-14 01:08 喵星人与汪星人 阅读(219) 评论(0) 推荐(0) 编辑

[leetcode]String to Integer (atoi)
摘要:String to Integer (atoi)Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, plea... 阅读全文

posted @ 2014-08-14 00:23 喵星人与汪星人 阅读(230) 评论(0) 推荐(0) 编辑

JDK源码分析之String篇
摘要:------------------------------String在内存中的存储情况(一下内容摘自参考资料1)-----------------------------------前提:先了解下什么是声明,什么时候才算是产生了对象实例其中x并未看到内存分配,变量在使用前必须先声明,再赋值,然后... 阅读全文

posted @ 2014-08-13 01:01 喵星人与汪星人 阅读(3100) 评论(1) 推荐(2) 编辑

[leetcode]Sort Colors
摘要:Sort ColorsGiven an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the or... 阅读全文

posted @ 2014-08-11 21:48 喵星人与汪星人 阅读(253) 评论(0) 推荐(0) 编辑

[leetcode]Search a 2D Matrix
摘要:Search a 2D MatrixWrite an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row... 阅读全文

posted @ 2014-08-11 20:07 喵星人与汪星人 阅读(133) 评论(0) 推荐(0) 编辑

[leetcode]Binary Tree Maximum Path Sum
摘要:Binary Tree Maximum Path SumGiven a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the be... 阅读全文

posted @ 2014-08-11 19:43 喵星人与汪星人 阅读(212) 评论(0) 推荐(0) 编辑

[leetcode]Maximum Subarray
摘要:Maximum SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−... 阅读全文

posted @ 2014-08-10 19:47 喵星人与汪星人 阅读(202) 评论(0) 推荐(0) 编辑

[leetcode]First Missing Positive
摘要:First Missing PositiveGiven an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Yo... 阅读全文

posted @ 2014-08-09 22:32 喵星人与汪星人 阅读(167) 评论(0) 推荐(0) 编辑

[leetcode]Sudoku Solver
摘要:Sudoku SolverWrite a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character'.'.You may assume that the... 阅读全文

posted @ 2014-08-09 21:17 喵星人与汪星人 阅读(213) 评论(0) 推荐(0) 编辑

[leetcode]Valid Sudoku
摘要:Valid SudokuDetermine if a Sudoku is valid, according to:Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are ... 阅读全文

posted @ 2014-08-09 20:38 喵星人与汪星人 阅读(279) 评论(0) 推荐(0) 编辑

[leetcode]Search in Rotated Sorted Array
摘要:Search in Rotated Sorted ArraySuppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).... 阅读全文

posted @ 2014-08-09 16:57 喵星人与汪星人 阅读(268) 评论(0) 推荐(0) 编辑

[leetcode]Search for a Range
摘要:Search for a RangeGiven a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity ... 阅读全文

posted @ 2014-08-09 16:10 喵星人与汪星人 阅读(273) 评论(0) 推荐(0) 编辑

[leetcode]Search Insert Position
摘要:Search Insert PositionGiven a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if ... 阅读全文

posted @ 2014-08-09 15:47 喵星人与汪星人 阅读(223) 评论(0) 推荐(0) 编辑

[leetcode]Unique Paths II
摘要:Unique Paths IIFollow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle an... 阅读全文

posted @ 2014-08-08 22:43 喵星人与汪星人 阅读(191) 评论(0) 推荐(0) 编辑

[leetcode]Unique Paths
摘要:Unique PathsA robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right a... 阅读全文

posted @ 2014-08-08 22:23 喵星人与汪星人 阅读(219) 评论(0) 推荐(0) 编辑

[leetcode]Binary Tree Postorder Traversal
摘要:Binary Tree Postorder TraversalGiven a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \... 阅读全文

posted @ 2014-08-08 22:00 喵星人与汪星人 阅读(160) 评论(0) 推荐(0) 编辑

[leetcode]Binary Tree Level Order Traversal II
摘要:Binary Tree Level Order Traversal IIGiven a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level... 阅读全文

posted @ 2014-08-08 21:35 喵星人与汪星人 阅读(143) 评论(0) 推荐(0) 编辑

[leetcode]Binary Tree Level Order Traversal
摘要:Binary Tree Level Order TraversalGiven a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).Fo... 阅读全文

posted @ 2014-08-08 21:26 喵星人与汪星人 阅读(254) 评论(0) 推荐(0) 编辑

[leetcode]Binary Tree Zigzag Level Order Traversal
摘要:Binary Tree Zigzag Level Order TraversalGiven a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then... 阅读全文

posted @ 2014-08-08 21:11 喵星人与汪星人 阅读(208) 评论(0) 推荐(0) 编辑

[leetcode]Divide Two Integers
摘要:Divide Two IntegersDivide two integers without using multiplication, division and mod operator.不用* 、/、%来做除法。只能加减了啊亲!算法思路:一个一个加上去必超时,例如dividend = Integ... 阅读全文

posted @ 2014-08-08 18:30 喵星人与汪星人 阅读(315) 评论(0) 推荐(0) 编辑

[leetcode]Regular Expression Matching
摘要:Regular Expression MatchingImplement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more o... 阅读全文

posted @ 2014-08-08 16:37 喵星人与汪星人 阅读(368) 评论(0) 推荐(0) 编辑

[leetcode]Median of Two Sorted Arrays
摘要:Median of Two Sorted ArraysThere are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run... 阅读全文

posted @ 2014-08-08 15:13 喵星人与汪星人 阅读(233) 评论(0) 推荐(0) 编辑

[leetcode]Container With Most Water
摘要:Container With Most WaterGivennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such t... 阅读全文

posted @ 2014-08-08 11:21 喵星人与汪星人 阅读(182) 评论(0) 推荐(0) 编辑

[leetcode]Trapping Rain Water
摘要:Trapping Rain WaterGivennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to tr... 阅读全文

posted @ 2014-08-08 11:07 喵星人与汪星人 阅读(145) 评论(0) 推荐(0) 编辑

[leetcode]Jump Game II
摘要:Jump Game IIGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents... 阅读全文

posted @ 2014-08-08 00:44 喵星人与汪星人 阅读(246) 评论(0) 推荐(0) 编辑

[leetcode]Jump Game
摘要:Jump GameGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents yo... 阅读全文

posted @ 2014-08-08 00:29 喵星人与汪星人 阅读(247) 评论(0) 推荐(0) 编辑

[leetcode]Sqrt(x)
摘要:Sqrt(x)Implementint sqrt(int x).Compute and return the square root ofx.【注意】:1.本题int类型可能会溢出,因此不能用乘法运算,应尽量用除法。2. 绝大多数数字都不是可开方的,该如何得到比较近的结果呢?算法思路:思路1:顺序遍... 阅读全文

posted @ 2014-08-08 00:05 喵星人与汪星人 阅读(301) 评论(0) 推荐(0) 编辑

[leetcode]Flatten Binary Tree to Linked List
摘要:Flatten Binary Tree to Linked ListGiven a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / ... 阅读全文

posted @ 2014-08-07 22:53 喵星人与汪星人 阅读(210) 评论(0) 推荐(0) 编辑

[leetcode]Single Number II
摘要:Single Number IIGiven an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a lin... 阅读全文

posted @ 2014-08-07 22:26 喵星人与汪星人 阅读(167) 评论(0) 推荐(0) 编辑

[leetcode]Surrounded Regions
摘要:Surrounded RegionsGiven a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in that... 阅读全文

posted @ 2014-08-07 21:02 喵星人与汪星人 阅读(606) 评论(0) 推荐(0) 编辑

[leetcode]Palindrome Partitioning II
摘要:Palindrome Partitioning IIGiven a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a p... 阅读全文

posted @ 2014-08-07 19:39 喵星人与汪星人 阅读(244) 评论(0) 推荐(0) 编辑

[leetcode]Longest Consecutive Sequence
摘要:Longest Consecutive SequenceGiven an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4... 阅读全文

posted @ 2014-08-07 16:23 喵星人与汪星人 阅读(185) 评论(0) 推荐(0) 编辑

排序算法(初级版)之快排、归并、堆排序
摘要:排序算法是算法中的基础,也是面试常问常考的算法之一,今天先简单整理一下最常考的三个排序算法。以后有空(希望有空)了再统一优化一下。七大排序算法的复杂度分析排序算法最坏时间辅助度平均时间复杂度空间复杂度稳定性备注冒泡排序 O(n^2) O(n^2) O(1)YES交换排序 O(n^2) O(... 阅读全文

posted @ 2014-08-06 23:49 喵星人与汪星人 阅读(340) 评论(0) 推荐(0) 编辑

[leetcode]Best Time to Buy and Sell Stock II
摘要:Best Time to Buy and Sell Stock IISay you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the ... 阅读全文

posted @ 2014-08-06 22:58 喵星人与汪星人 阅读(197) 评论(0) 推荐(0) 编辑

[leetcode]Best Time to Buy and Sell Stock
摘要:Best Time to Buy and Sell StockSay you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to compl... 阅读全文

posted @ 2014-08-06 22:44 喵星人与汪星人 阅读(126) 评论(0) 推荐(0) 编辑

[leetcode]Copy List with Random Pointer
摘要:Copy List with Random PointerA linked list is given such that each node contains an additional random pointer which could point to any node in the lis... 阅读全文

posted @ 2014-08-06 15:42 喵星人与汪星人 阅读(125) 评论(0) 推荐(0) 编辑

Spring IOC原理(初级版)
摘要:Spring框架是由于软件开发的复杂性而创建的。Spring使用的是基本的JavaBean来完成以前只可能由EJB完成的事情。然而,Spring的用途不仅仅限于服务器端的开发。从简单性、可测试性和松耦合性的角度而言,绝大部分Java应用都可以从Spring中受益。------------------... 阅读全文

posted @ 2014-08-06 01:06 喵星人与汪星人 阅读(221) 评论(0) 推荐(0) 编辑

Hibernate框架简介
摘要:面试被问及了Hibernate框架,虽然问的很少,很简单,但是还是简单的总结一下吧,以备以后不时之需。什么是Hibernate框架?百科定义:Hibernate框架式一个开源的对象关系映射(ORM)框架,是对JDBC的轻量级的对象封装,使java程序员可以使用对象思维来操纵DB。白话版:在Hiber... 阅读全文

posted @ 2014-08-05 22:48 喵星人与汪星人 阅读(2811) 评论(0) 推荐(0) 编辑

[leecode]Evaluate Reverse Polish Notation
摘要:Evaluate Reverse Polish NotationEvaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may ... 阅读全文

posted @ 2014-08-05 10:28 喵星人与汪星人 阅读(113) 评论(0) 推荐(0) 编辑

[leetcode]Word Break
摘要:Word BreakGiven a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.... 阅读全文

posted @ 2014-08-05 01:06 喵星人与汪星人 阅读(630) 评论(0) 推荐(0) 编辑

[leetcode]Gas Station
摘要:Gas StationThere areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and it... 阅读全文

posted @ 2014-08-05 00:21 喵星人与汪星人 阅读(240) 评论(0) 推荐(0) 编辑

[leetcode]Candy
摘要:CandyThere areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following ... 阅读全文

posted @ 2014-08-04 23:59 喵星人与汪星人 阅读(181) 评论(0) 推荐(0) 编辑

java集合框架小结(进阶版)之HashSet篇
摘要:建议先看下:java集合框架小结(进阶版)之HashMap篇基本概念:hashSet:根据java集合框架小结(初级版)图示,HashSet是AbstractSet的一个子类,是基于Hash算法的Set接口的实现,顾名思义。允许添加null。-----------------------------... 阅读全文

posted @ 2014-08-04 21:30 喵星人与汪星人 阅读(187) 评论(0) 推荐(0) 编辑

java集合框架小结(进阶版)之HashMap篇
摘要:基本概念:Hash(哈希):hash一般也译作“散列”。事实上,就是一个函数,用于直接定址。将数据元素的关键字key作为变量,通过哈希函数,计算生成该元素的存储地址。冲突:函数是可以多对一的。即:多个自变量可以映射到同一函数值。一般而言,不同的key的hash值是不同的。在往hash表中映射的时候,... 阅读全文

posted @ 2014-08-04 21:07 喵星人与汪星人 阅读(395) 评论(0) 推荐(0) 编辑

java集合框架小结(初级版)
摘要:今天大概的整理了一下java集合框架,在这里做一个小结,方便以后查阅,本博文主要参考资料为《java编程思想第四版》第11章——持有对象以及JAVA 1.6 API文档。并没有研究更深入的第17章。大概介绍了集合框架中几个比较常用的集合类。以下为正文。首先来看一张图,不太会用visio,画的可能不太... 阅读全文

posted @ 2014-08-04 03:06 喵星人与汪星人 阅读(531) 评论(0) 推荐(0) 编辑

[leetcode]Decode Ways
摘要:Decode WaysA message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded me... 阅读全文

posted @ 2014-08-03 14:55 喵星人与汪星人 阅读(283) 评论(0) 推荐(0) 编辑

[leetcode]Distinct Subsequences
摘要:Distinct SubsequencesGiven a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is... 阅读全文

posted @ 2014-08-02 02:46 喵星人与汪星人 阅读(338) 评论(0) 推荐(0) 编辑

[leetcode]Longest Valid Parentheses
摘要:Longest Valid ParenthesesGiven a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substr... 阅读全文

posted @ 2014-08-02 02:01 喵星人与汪星人 阅读(1514) 评论(2) 推荐(0) 编辑

[leetcode]Edit distance
摘要:Edit DistanceGiven two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You... 阅读全文

posted @ 2014-08-01 22:36 喵星人与汪星人 阅读(387) 评论(0) 推荐(0) 编辑

[leetcode]Anagrams
摘要:AnagramsGiven an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.编程珠玑中的一道题,书中的解法很巧妙,我就直接搬来用了,时... 阅读全文

posted @ 2014-08-01 19:56 喵星人与汪星人 阅读(359) 评论(0) 推荐(0) 编辑

[leetcode]Text Justification
摘要:Text JustificationGiven an array of words and a lengthL, format the text such that each line has exactlyLcharacters and is fully (left and right) just... 阅读全文

posted @ 2014-08-01 19:21 喵星人与汪星人 阅读(996) 评论(0) 推荐(0) 编辑

[leetcode]Single Number
摘要:Single NumberGiven an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runti... 阅读全文

posted @ 2014-08-01 00:52 喵星人与汪星人 阅读(121) 评论(0) 推荐(0) 编辑

[leetcode]Longest Palindromic Substring
摘要:Longest Palindromic SubstringGiven a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there... 阅读全文

posted @ 2014-08-01 00:32 喵星人与汪星人 阅读(288) 评论(0) 推荐(0) 编辑