leetcode解题
文章平均质量分 62
yushuifirst
这个作者很懒,什么都没留下…
展开
-
最长回文子字符串问题
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 palindr原创 2015-05-12 16:25:27 · 402 阅读 · 0 评论 -
Reverse Integer反转int数问题
Reverse Integer反转int数问题 Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 注意int数溢出问题,当溢出是返回0;java代码public static int reverse(int x) { lo原创 2015-05-13 20:33:13 · 482 阅读 · 0 评论 -
leetcode subsets问题
Leetcode:Subsets 求数组的所有子集 Given a set of distinct integers, S , return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution set must not contai原创 2015-05-06 21:45:08 · 331 阅读 · 0 评论 -
Longest Substring Without Repeating Characters问题--解题笔记
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原创 2015-05-07 21:23:48 · 365 阅读 · 0 评论 -
Valid Parentheses问题
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 “()[]{}”原创 2015-05-29 19:53:26 · 345 阅读 · 0 评论 -
Letter Combinations of a Phone Number
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 bu原创 2015-05-18 22:17:18 · 287 阅读 · 0 评论 -
Longest Common Prefix字符串最长公共前缀问题
Longest Common Prefix字符串最长公共前缀问题 Write a function to find the longest common prefix string amongst an array of strings. java代码public static String longestCommonPrefix(String[] strs) { if(strs.le原创 2015-05-18 22:12:33 · 472 阅读 · 0 评论 -
median of two sorted arrays
题目:求两个已排序数组合并之后形成的排序数组的中位数。思路一:利用归并排序的思想分别从两个数组中取数据,直到取到第(m+n)/2数据为止(m、n分别为两个数组A、B的长度)。思路二:将原问题转变成一个寻找两个已排序数组中前k小数的问题。在此的k等于(m+n)/2。首先假设数组A和B的元素个数都大于k/2,我们比较A[k/2-1]和B[k/2-1]两个元素,这两个元素分别表示A的第k/2小的元素和B原创 2015-08-05 11:03:00 · 355 阅读 · 0 评论 -
leetcode算法思路总结
算leetcode法思路总结1.Minimum Window Substring问题 Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example, S = “ADOBE原创 2015-08-05 17:28:47 · 1295 阅读 · 0 评论