- 博客(12)
- 收藏
- 关注
原创 (Java)LeetCode-21. Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.这道题和之前的合并已排序的数组的思路一样的,就是变成了链表而已,稍稍复杂一点。/** *
2016-05-31 14:59:27 179
原创 (Java)LeetCode-20. Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va
2016-05-31 13:51:33 207
原创 (Java)LeetCode-19. Remove Nth Node From End of List
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the
2016-05-31 00:00:58 540
原创 (Java)LeetCode-18. 4Sum
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 which gives the sum of target.Note:Element
2016-05-30 19:59:46 1724
原创 (Java)LeetCode-17. Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit st
2016-05-29 22:35:46 1324 1
原创 (Java)LeetCode-16. 3Sum Closest
Given 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 would have exact
2016-05-29 21:24:31 247
原创 (java)Leetcode-15. 3Sum
Given 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:Elements in a triplet (a,b,c
2016-05-25 17:53:58 592
原创 (JAVA)LeetCode-14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.这道题其实蛮简单的,就是找公共前缀,先找前两个的公共前缀,再加上第三个,一直到最后即可,可是我刚看了trie树,本想装个×,结果速度好慢。以下是我的代码,用所有的字符串组成一个trie树,然后从树根开始,如果哪一
2016-05-24 20:01:53 262
原创 (Java)LeetCode-13. Roman to Integer
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.这一题和上一题姊妹题~同样的方法,反过来即可,easy~public class Solution { public int roman
2016-05-10 23:27:14 766
原创 (Java)LeetCode-12. Integer to Roman
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.其实做这一题的时候宝宝是拒绝的,好无趣~又不懂转换规则,然后就在网上看了个解法,蛮简单滴。略过吧~public class Solution { pub
2016-05-10 23:13:07 805
原创 LeetCode-11. Container With Most Water
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Fin
2016-05-10 19:46:39 767
原创 LeetCode-10. Regular Expression Matching
Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input st
2016-05-05 21:11:20 207
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人