【026-Remove Duplicates from Sorted Array(删除排序数组中的重复元素)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a sorted array, remove the duplicates in place such that each element appear only once and return the...
分类:
编程语言 时间:
2015-07-24 08:06:09
阅读次数:
191
【021-Merge Two Sorted Lists(合并两个排好序的单链表)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of t...
分类:
编程语言 时间:
2015-07-23 08:16:37
阅读次数:
164
【022-Generate Parentheses(生成括号)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
For example, given n = 3...
分类:
编程语言 时间:
2015-07-23 08:15:55
阅读次数:
137
【020-Valid Parentheses(括号验证)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.
The brackets...
分类:
编程语言 时间:
2015-07-22 09:30:07
阅读次数:
141
【018-4Sum(四个数的和)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given 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...
分类:
编程语言 时间:
2015-07-22 09:28:28
阅读次数:
147
【017-Letter Combinations of a Phone Number (电话号码上的单词组合)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a digit string, return all possible letter combinations that the number could represent.
A mapping...
分类:
编程语言 时间:
2015-07-21 09:11:42
阅读次数:
133
【014-Longest Common Prefix(最长公共前缀)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Write a function to find the longest common prefix string amongst an array of strings.
题目大意 写一个函数找出一个字串所数组中的最长的公共前缀。
解题思路 第一...
分类:
编程语言 时间:
2015-07-20 09:18:51
阅读次数:
183
【009-Palindrome Number(回文数)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】题目大意 判断一个数字是否是回访字数,不要使用额外的空间。 解题思路 为了不使用额外的空间,参考了其它的解决,那些解法看起来在isPalindrome方法中没有使用额外参数,但是却使用了方法调用,这个比一个整数消耗的空间更多 ,并没有达到题目的要求,是假的实现,所以本题依然采用一个额外的空间...
分类:
编程语言 时间:
2015-07-19 10:12:39
阅读次数:
240
【011-ContainerWithMostWater(容纳最多的水)】找两条竖线然后这两条线以及X轴构成的容器能容纳最多的水。使用贪心算法
1.首先假设我们找到能取最大容积的纵线为 i, j (假定i < j),那么得到的最大容积 C = min( ai , aj ) * ( j- i) ;
2.下面我们看这么一条性质:
①: 在 j 的右端没有一条线会比它高!假设存在 k |( j < k && ak...
分类:
编程语言 时间:
2015-07-19 10:11:38
阅读次数:
123
【010-Regular Expresssion Matching(正则表达式匹配)】实现一个正则表达式匹配算法,.匹配任意一个字符,*匹配0个或者多个前导字符。使用标记匹配算法法,从后向前进行匹配。...
分类:
编程语言 时间:
2015-07-19 10:10:27
阅读次数:
152