- 博客(18)
- 资源 (1)
- 收藏
- 关注
原创 [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. 直接上代码了。 java /** * Definition for singly-linked list
2016-10-19 20:39:45 227
原创 [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-10-19 20:22:25 355
原创 [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-10-19 00:03:11 237
原创 [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: The solution
2016-10-18 23:25:16 261
原创 [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:Di
2016-10-18 23:20:01 243
原创 [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-10-17 22:34:23 233
原创 [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: The solution set must not contain
2016-10-17 22:19:46 229
原创 [leetcode]14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. 比较简单,直接上代码。 java代码 public class Solution { public String longestCommonPrefix(String[] strs) { if(s
2016-10-15 21:49:09 225
原创 [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. 这道题和12题正好相反,但是要比12题难一点。最重要的还是要熟悉对应表。 1~9: {"I", "II", "III", "IV", "V", "VI", "VI
2016-10-15 18:21:39 226
原创 [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. 这道题基本没什么算法上的难点,就是需要知道罗马字母和整数的对应关系就行了。 1~9: {"I", "II", "III", "IV", "V", "VI", "V
2016-10-15 18:13:54 240
原创 [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-10-13 23:21:08 238
原创 [leetcode] 9. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of convertin
2016-10-13 23:07:45 250
原创 [leetcode]7. Reverse Integer
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Have you thought about this? Here are some good questions to ask before c
2016-10-10 22:47:49 251
原创 [leetcode]5. Longest Palindromic Substring
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 本题是求一个字符串的最长的回文子串。
2016-10-10 22:09:20 200
原创 [leetcode]4. Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example 1: nums1 =
2016-10-09 21:31:38 207
原创 [leetcode]3. Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the length is 3. Given "bbbbb", the answer is "
2016-10-09 00:03:03 235
原创 [leetcode] 2. Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link
2016-10-07 21:34:40 245
原创 [leetcode] 1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution. Example: Given nums =
2016-10-07 17:30:22 334
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人