自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(65)
  • 收藏
  • 关注

原创 Elasticsearch源码编译运行

下载源码从https://github.com/elastic/elasticsearch上下载相应版本的源代码,本人下载的是5.4.2版本的源代码获取相关依赖Elasticsearch在5.4版本是采用gradle来管理的,进入源码的根目录,因为我用的是idea编译器,因此执行:gradle idea然后进入漫长的下载相关依赖包的过程导入idea在Idea中导入Elasticsearch源码,入口

2017-06-23 15:50:22 7615 1

原创 二叉查找树

一、LeetCodeMediumUnique Binary Search TreesUnique Binary Search Trees II【TIMEOUT】Validate Binary Search TreeHardRecover Binary Search Tree【TIMEOUT】

2017-05-10 19:15:56 199

原创 Recover Binary Search Tree

一. Recover Binary Search TreeTwo 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 pretty straight forw

2017-05-10 19:10:08 236

原创 Validate Binary Search Tree

一. Validate Binary Search TreeGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less

2017-05-10 18:58:19 210

原创 Unique Binary Search Trees

一. Unique Binary Search TreesGiven n, how many structurally unique BST’s (binary search trees) that store values 1…n?For example, Given n = 3, there are a total of 5 unique BST’s. 1 3

2017-05-10 16:57:20 211

原创 Gray Code

一. Gray CodeThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the seque

2017-04-26 16:27:47 175

原创 Scramble String

一. Scramble StringGiven a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = “great”: great /

2017-04-26 16:00:06 231

原创 Maximal Rectangle

一. Maximal RectangleGiven a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area.For example, given the following matrix: 1 0 1 0 0 1 0 1 1

2017-04-25 14:43:06 224

原创 Largest Rectangle in Histogram

一. Largest Rectangle in HistogramGiven n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a h

2017-04-24 16:22:09 202

原创 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).For example, S = “ADOBECODEBANC” T = “ABC”

2017-04-19 15:29:20 168

原创 Edit Distance

一. Edit DistanceGiven two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted

2017-04-17 14:12:28 264

原创 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 problem statement

2017-04-15 15:04:51 228

原创 Unique Paths

一. Unique PathsA robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to

2017-04-14 20:54:29 151

原创 Permutation Sequence

一. Permutation SequenceThe set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3): “12

2017-04-13 19:55:47 209

原创 Insert Interval

一. Insert IntervalGiven a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their star

2017-04-13 12:35:29 194

原创 Spiral Matrix

一. Spiral MatrixGiven a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example, Given the following matrix: [ [ 1, 2, 3 ], [ 4, 5, 6 ],

2017-04-09 19:07:39 177

原创 Pow(x, n)

一. Pow(x, n)Implement pow(x, n).Difficulty:MediumTIME:20MIN解法一(递归)这道题是求某个数的n次幂,按我们正常的思维来说,可能就是求n次乘法算得结果,时间复杂度为O(n)O(n)。假设是求x8x^8,我们可以分解为8个xx相乘,同样,我们也可以分解为((x2)2)2((x^2)^2)^2,但这个时候,我们就只需要三次乘法。因此,快速幂的要诀就

2017-04-08 14:04:10 224

原创 N-Queens

一. N-QueensThe n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle

2017-04-08 12:24:19 187

原创 Permutations II

一. Permutations IIGiven a collection of numbers that might contain duplicates, return all possible unique permutations.For example, [1,1,2] have the following unique permutations: [ [1,1,2],

2017-04-06 19:31:21 114

原创 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 your maximum jump length at that position.Your

2017-04-06 18:53:52 142

原创 Wildcard Matching

一. Wildcard MatchingImplement wildcard pattern matching with support for ‘?’ and ‘*’.‘?’ Matches any single character. ‘*’ Matches any sequence of characters (including the empty sequence).The matchin

2017-04-05 18:39:40 127

原创 Multiply Strings

一. Multiply StringsGiven two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2.Note:The length of both num1 and num2 is < 110.Both num1 and num2 contains

2017-04-05 13:45:04 144

原创 Trapping Rain Water

一. Trapping Rain WaterGiven n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. For example, Given [0,

2017-04-04 21:50:31 135

原创 First Missing Positive

一. First Missing PositiveGiven an unsorted integer array, find the first missing positive integer.For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2.Your algorithm should run in O(n) ti

2017-04-03 20:45:14 151

原创 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 there will be only one unique solution.A sudoku pu

2017-04-03 18:35:28 191

原创 Longest Valid Parentheses

一. Longest Valid ParenthesesGiven a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.For “(()”, the longest valid parentheses

2017-03-31 20:50:46 193

原创 Next Permutation

一. Next Permutationmplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lo

2017-03-31 00:00:33 183

原创 Divide Two Integers

一. Divide Two IntegersDivide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.Difficulty:MediumTIME:TIMEOUT解法实现整数的除法,不能用乘法除法以及取余。因此就剩下加减法,用加减法当然可以,

2017-03-30 00:26:00 282

原创 Reverse Nodes in k-Group

一. Reverse Nodes in k-GroupGiven a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to the length of the linked

2017-03-29 22:20:08 137

原创 Merge k Sorted Lists

一. Merge k Sorted ListsMerge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Difficulty:HardTIME:16MIN解法一我们都知道合并两个有序的列表,时间复杂度为O(n)O(n),但如果是合并k个列表呢?最简单的做法当然是每

2017-03-28 19:59:20 157

原创 4Sum

一. 4SumGiven an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: The solution

2017-03-26 18:58:40 145

原创 3Sum Closest

一. 3Sum ClosestGiven an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input woul

2017-03-24 22:07:37 125

原创 3Sum

一. 3SumGiven an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain

2017-03-24 21:52:48 149

原创 Longest Common Prefix

一. Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.Difficulty:EasyTIME:16MIN解法在很多的字符串中寻找这些字符串的最长公共前缀。当然没什么难度,我这里使用了一个prefix作为当前找到的最长公共前缀,然后依次匹

2017-03-24 16:15:48 109

原创 Roman to Integer

一. Roman to IntegerGiven a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.Difficulty:EASYTIME:7MIN解法这道题由于之前做过Integer to Roman,因此没有什么特别大的难度。int romanTo

2017-03-24 15:53:10 146

原创 Integer to Roman

一. Integer to RomanGiven an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.Difficulty:MediumTIME:30MIN解法不得不说这道题的题目是很精简的,连一个例子都没有。当然,如果理解了罗马数字的表示方法, 那么这

2017-03-24 15:38:29 173

原创 Container With Most Water

一. Container With Most WaterGiven n non-negative integers a1a_1, a2a_2, …, ana_n, where each represents a point at coordinate (i, aia_i). n vertical lines are drawn such that the two endpoints of line

2017-03-23 20:51:03 152

原创 Regular Expression Matching

一. Regular Expression MatchingImplement regular expression matching with support for ‘.’ and ‘*’.‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element.The matching should

2017-03-23 19:23:59 149

原创 String to Integer (atoi)

一. String to Integer (atoi)Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are

2017-03-21 20:57:09 205

原创 Arithmetic Slices II - Subsequence

一. Arithmetic Slices II - SubsequenceA sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For exam

2017-03-21 19:35:46 204

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除