
leetcode
文章平均质量分 52
zb_possible
这个作者很懒,什么都没留下…
展开
-
79. Word Search
Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically原创 2016-04-06 22:29:34 · 200 阅读 · 0 评论 -
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 m原创 2016-06-13 23:15:30 · 229 阅读 · 0 评论 -
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原创 2016-06-13 21:55:27 · 235 阅读 · 0 评论 -
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-06-13 21:13:23 · 242 阅读 · 0 评论 -
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.二,代码public ListNode mergeTwoLists(ListNode原创 2016-06-13 17:16:17 · 228 阅读 · 0 评论 -
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 "()[]{}" ar原创 2016-06-13 16:59:18 · 183 阅读 · 0 评论 -
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 th原创 2016-06-13 16:07:10 · 184 阅读 · 0 评论 -
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 ha原创 2016-06-13 15:12:28 · 198 阅读 · 0 评论 -
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 n原创 2016-06-13 13:32:17 · 172 阅读 · 0 评论 -
1,Two Sum
1,题目: 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-06-07 00:25:17 · 191 阅读 · 0 评论 -
14. Longest Common Prefix
一,题目Write a function to find the longest common prefix string amongst an array of strings.二,思路使用StringBuffer存储相同的前缀.使用暴力枚举的办法,每次取出一个字符串,然后都与第一个字符串的相同位置字符比较.相同则继续,否则返回StringBuffer存储的内容三,代原创 2016-06-11 00:42:49 · 193 阅读 · 0 评论 -
9. Palindrome Number
一,题目Determine whether an integer is a palindrome. Do this without extra space.二,思路和整数翻转一样注意:负数都不是回文三,代码public boolean isPalindrome(int x) { if (x < 0) { return false;原创 2016-06-10 23:22:44 · 188 阅读 · 0 评论 -
8. 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 inpu原创 2016-06-10 21:52:24 · 191 阅读 · 0 评论 -
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 l原创 2016-06-10 00:05:05 · 219 阅读 · 0 评论 -
7. Reverse Integer
一,题目Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321二,思路用一个变量记录转换的值每次模10取得最低位,记录的变量值乘以10然后加上这个最低位这个数字再除以10三,代码public int reverse(原创 2016-06-10 00:01:10 · 236 阅读 · 0 评论 -
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-06-08 02:04:38 · 189 阅读 · 0 评论 -
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 a原创 2016-06-08 00:28:19 · 212 阅读 · 0 评论 -
32. Longest Valid Parentheses
一,题目Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring i原创 2016-06-18 20:55:40 · 239 阅读 · 0 评论