![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
如故1994
趁秋雨还未滴落 趁风霜还未曾侵蚀
展开
-
[LeetCode-Java]1.TwoSum
LeetCode TwoSum原创 2016-09-18 20:07:50 · 352 阅读 · 0 评论 -
[LeetCode]20. Valid Parentheses
20. Valid Parentheses原创 2016-09-22 15:26:19 · 211 阅读 · 0 评论 -
[LeetCode-Java]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-09-22 15:37:39 · 195 阅读 · 0 评论 -
[LeetCode-Java]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). Find two lin原创 2016-09-26 21:03:57 · 288 阅读 · 0 评论 -
[LeetCode-Java]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 duplic原创 2016-09-27 22:43:23 · 271 阅读 · 0 评论 -
[LeetCode-Java]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 exactly原创 2016-09-28 15:42:03 · 276 阅读 · 0 评论 -
[LeetCode-Java]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 set mu原创 2016-09-28 16:43:28 · 325 阅读 · 0 评论 -
[LeetCode-Java]22. Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ “((()))”, “(()())”, “(())()”, “()(())”,原创 2016-09-28 18:39:22 · 229 阅读 · 0 评论 -
[LeetCode-Java]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 string “2原创 2016-09-29 15:01:53 · 273 阅读 · 0 评论 -
[LeetCode-Java]29. Divide Two Integers
Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.解:题目不能用乘除法和取余运算,直接迭代相减又会超时(时间复杂度O(n)),考虑使用移位运算。 比如20/3 , 20 = 3*2^2+3*2^1+2 , 因而20/原创 2016-10-03 22:05:04 · 310 阅读 · 0 评论 -
[LeetCode-Java]31. Next Permutation
Implement 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 lowest possible orde原创 2016-10-03 23:05:13 · 252 阅读 · 0 评论 -
[LeetCode-Java]34. Search for a Range
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm’s runtime complexity must be in the order of O(log n).If the target is not found in the ar原创 2016-10-04 14:21:25 · 310 阅读 · 0 评论 -
[LeetCode-Java]35. Search Insert Position
Given 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 it were inserted in order.You may assume no duplicates in the array.Here原创 2016-10-04 14:42:31 · 307 阅读 · 0 评论 -
[LeetCode-Java]39. Combination Sum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited number of t原创 2016-10-06 22:01:58 · 351 阅读 · 0 评论 -
[LeetCode-Java]40. Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combination.No原创 2016-10-07 22:00:21 · 365 阅读 · 0 评论 -
[LeetCode-Java]46. Permutations
Given a collection of distinct numbers, return all possible permutations.For example, [1,2,3] have the following permutations: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]原创 2016-10-19 22:23:21 · 970 阅读 · 0 评论 -
[LeetCode-Java]24. Swap Nodes in Pairs
24. Swap Nodes in Pairs原创 2016-09-22 15:23:56 · 252 阅读 · 0 评论 -
[LeetCode-Java]3. Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.原创 2016-09-24 21:26:01 · 204 阅读 · 0 评论 -
[LeetCode-Java]6. ZigZag Conversion
zigzagconversion原创 2016-09-18 22:39:24 · 244 阅读 · 0 评论 -
[LeetCode-Java]26. Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with cons原创 2016-09-22 16:42:39 · 194 阅读 · 0 评论 -
[LeetCode-Java]43. Multiply Strings
Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative. Converting the input string to integer is N原创 2016-10-08 20:34:31 · 1206 阅读 · 0 评论 -
[LeetCode-Java]7. Reverse Integer
reverse integer原创 2016-09-19 21:00:36 · 257 阅读 · 0 评论 -
[LeetCode-Java]8. String to Integer (atoi)
string to integer原创 2016-09-19 22:46:11 · 269 阅读 · 0 评论 -
[LeetCode-Java]27. Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.The order原创 2016-09-23 10:24:17 · 214 阅读 · 0 评论 -
[LeetCode-Java]28. Implement strStr()
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.原创 2016-09-23 11:07:09 · 361 阅读 · 0 评论 -
[LeetCode-Java]36. Valid Sudoku
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character ‘.’.Note: A valid Sudoku board (par原创 2016-09-23 16:29:21 · 308 阅读 · 0 评论 -
[LeetCode-Java]38. Count and Say
The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, …1 is read off as “one 1” or 11. 11 is read off as “two 1s” or 21. 21 is read off as “one 2, the原创 2016-09-23 19:48:18 · 199 阅读 · 0 评论 -
[LeetCode-Java]9. Palindrome Number
Palindrome Number原创 2016-09-20 19:39:42 · 297 阅读 · 0 评论 -
[LeetCode-Java]13. Roman to Integer
Roman to Integer原创 2016-09-20 20:45:27 · 346 阅读 · 0 评论 -
[LeetCode-Java]14. Longest Common Prefix
14. Longest Common Prefix原创 2016-09-20 22:15:34 · 342 阅读 · 0 评论 -
[LeetCode-Java]19. Remove Nth Node From End of List
19. Remove Nth Node From End of List原创 2016-09-21 13:26:16 · 256 阅读 · 0 评论 -
[LeetCode-Java]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 linke原创 2016-09-24 16:41:46 · 200 阅读 · 0 评论 -
[LeetCode-Java]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 “b”, with the le原创 2016-09-24 17:10:56 · 222 阅读 · 0 评论 -
[LeetCode-Java]48. Rotate Image
You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).解1:很容易想到旋转后的矩阵位置对应关系为matrix_new[m][n] = matrix[matrix.length-1-n][m]; 因而,一种比较笨的方法是先把matrix复制,再取对应位置的值到原创 2016-11-24 10:36:48 · 613 阅读 · 0 评论