LeetCode
文章平均质量分 71
xyzchenzd
非淡泊无以明志,非宁静无以致远
展开
-
LeetCode Two Sum
题目Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, w原创 2014-05-06 18:23:00 · 449 阅读 · 0 评论 -
LeetCode Longest Substring Without Repeating Characters
题目Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3.原创 2014-05-08 16:27:29 · 420 阅读 · 0 评论 -
LeetCode Add Two Numbers
题目原创 2014-05-08 18:15:11 · 417 阅读 · 0 评论 -
LeetCode Median of Two Sorted Arrays
题目原创 2014-05-08 10:27:30 · 630 阅读 · 0 评论 -
LeetCode 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,原创 2014-05-14 19:51:09 · 331 阅读 · 0 评论 -
LeetCode 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 exa原创 2014-05-15 10:46:42 · 314 阅读 · 0 评论 -
LeetCode Longest Palindromic Substring
题目Given a string S, find the longest palindromic substring in S. You may assume that the maximum length ofS is 1000, and there exists one unique longest palindromic substring.原创 2014-05-09 16:49:09 · 430 阅读 · 0 评论 -
LeetCode 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:Eleme原创 2014-05-15 13:59:13 · 369 阅读 · 0 评论 -
LeetCode Reverse digits of an integer.
题目Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321原创 2014-05-12 14:25:44 · 461 阅读 · 0 评论 -
LeetCode 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:Dig原创 2014-05-17 13:23:13 · 382 阅读 · 0 评论 -
LeetCode 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, t原创 2014-05-17 13:25:35 · 348 阅读 · 0 评论 -
LeetCode 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 v原创 2014-05-17 13:28:48 · 388 阅读 · 0 评论 -
LeetCode Generate Parentheses
题目原创 2014-05-18 14:38:15 · 418 阅读 · 0 评论 -
LeetCode Merge k Sorted Lists
题目原创 2014-05-19 13:08:51 · 381 阅读 · 0 评论 -
LeetCode Swap Nodes in Pairs
题目Given a linked list, swapevery two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as2->1->4->3.Your algorithm should useonly constant space原创 2014-05-19 13:11:27 · 324 阅读 · 0 评论 -
LeetCode 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 the possible input原创 2014-05-12 14:29:46 · 585 阅读 · 0 评论 -
LeetCode Palindrome Number
题目Determine whether an integer is a palindrome. Do this without extra space.原创 2014-05-12 14:37:52 · 432 阅读 · 0 评论 -
LeetCode Roman to Integer
题目Given a roman numeral,convert it to an integer.Input is guaranteed to bewithin the range from 1 to 3999. 给罗马原创 2014-05-13 18:44:42 · 389 阅读 · 0 评论 -
LeetCode Integer to Roman
题目 Given an integer, convertit to a roman numeral.Input is guaranteed to bewithin the range from 1 to 3999.原创 2014-05-13 18:38:58 · 460 阅读 · 0 评论 -
LeetCode Regular Expression Matching
题目原创 2014-05-12 20:01:23 · 443 阅读 · 0 评论 -
LeetCode Container With Most Water
题目Given n non-negativeintegers a1,a2, ...,an, where each represents a point at coordinate (i,ai).n vertical linesare drawn such that the two endpoints of line i is at (i,ai) and (i, 0). Fi原创 2014-05-13 18:36:08 · 464 阅读 · 0 评论 -
LeetCode Reverse Nodes in k-Group
题目原创 2014-05-21 15:55:43 · 427 阅读 · 0 评论 -
LeetCode Longest Common Prefix
题目Write a function to findthe longest common prefix string amongst an array of strings. 求最长公共前缀,从头开始扫,注意数组为空,注意到字符串尾(尤其是同时到尾) 代码:原创 2014-05-14 19:43:00 · 432 阅读 · 0 评论 -
LeetCode ZigZag Conversion
题目原创 2014-05-09 19:17:23 · 541 阅读 · 0 评论 -
LeetCode Merge Two Sorted Lists
题目原创 2014-07-16 13:36:33 · 375 阅读 · 0 评论 -
LeetCode Search in Rotated Sorted Array
题目Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array return原创 2014-06-06 09:31:52 · 317 阅读 · 0 评论 -
LeetCode Search for a Range
题目原创 2014-06-07 12:22:07 · 372 阅读 · 0 评论 -
LeetCode Add Binary
题目Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100".原创 2014-07-17 11:08:07 · 442 阅读 · 0 评论 -
LeetCode Remove Duplicates from Sorted Array
题目Given a sorted array, remove the duplicates in place such that each element appear onlyonce and return the new length.Do not allocate extra space for another array, you must do this in place w原创 2014-05-24 14:43:18 · 368 阅读 · 0 评论 -
LeetCode 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'.'.A partially fill原创 2014-06-08 12:43:41 · 464 阅读 · 0 评论 -
LeetCode 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 arra原创 2014-06-07 12:28:22 · 412 阅读 · 0 评论 -
LeetCode Remove Element
题目原创 2014-05-24 14:46:21 · 331 阅读 · 0 评论 -
LeetCode Valid Number
题目Validate 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 to be ambi原创 2014-07-18 16:06:27 · 424 阅读 · 0 评论 -
LeetCode Sudoku Solver
题目Write 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原创 2014-06-08 13:03:50 · 539 阅读 · 0 评论 -
LeetCode Permutations
题目Given a collection of 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], and [3,2,1].原创 2014-06-28 09:52:28 · 371 阅读 · 0 评论 -
LeetCode Rotate Image
timYou are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?原创 2014-06-29 13:03:56 · 394 阅读 · 0 评论 -
LeetCode Permutations II
题目原创 2014-06-28 10:28:55 · 341 阅读 · 0 评论 -
LeetCode Implement strStr()
题目Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.原创 2014-05-25 13:09:01 · 414 阅读 · 0 评论 -
LeetCode Plus One
题目原创 2014-07-21 15:40:39 · 423 阅读 · 0 评论 -
LeetCode 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 "原创 2014-06-09 12:31:23 · 1010 阅读 · 0 评论