
LeetCode
文章平均质量分 53
King来写代码
代码心得
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCodeOJ——1.Tow Sum
Tow SumGiven 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 = [2原创 2016-09-13 19:31:49 · 538 阅读 · 0 评论 -
32. Longest Valid Parentheses
Longest Valid ParenthesesGiven a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.For “(()”, the longest valid parentheses sub原创 2016-10-05 07:41:44 · 502 阅读 · 0 评论 -
LeetCodeOJ——4. Median of Two Sorted Arrays
Median of Two Sorted ArraysThere 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)).Exam原创 2016-09-13 20:21:16 · 356 阅读 · 0 评论 -
LeetCode动态规划归纳
LeetCode动态规划归纳最近刷了很多动态规划的问题,归纳一下做动态规划的题的方法。动态规划很多题目是解决最多最少最大最小的问题。动态规划问题的基本做法是:确定递推量推出递推式确定边界在解决上述问题的同时,要时刻注意如何把全局的问题变成局部的(最优子结构),如何把前面计算过的子问题利用起来(重叠子问题)。下面把动态规划题分为几种类型。算种数的动态规划典型的题目包括:62.Unique Pa原创 2016-10-23 20:14:59 · 1827 阅读 · 1 评论 -
LeetCodeOJ——10. Regular Expression Matching
Regular Expression MatchingImplement regular expression matching with support for ‘.’ and ‘*’.‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element.The matching should co原创 2016-09-13 21:15:26 · 585 阅读 · 0 评论 -
LeetCodeOJ——8. String to Integer (atoi)
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 th原创 2016-09-13 20:56:33 · 426 阅读 · 0 评论 -
LeetCodeOJ——7. Reverse Integer
Reverse IntegerReverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321**spoilers: Have you thought about this? Here are some good questions to ask before coding. B原创 2016-09-13 20:52:54 · 389 阅读 · 0 评论 -
LeetCodeOJ——6. ZigZag Conversion
ZigZag ConversionThe string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H原创 2016-09-13 20:47:17 · 353 阅读 · 0 评论 -
LeetCodeOJ——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-09-13 20:29:07 · 383 阅读 · 0 评论 -
LeetCodeOJ——3. Longest Substring Without Repeating Characters
Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters.Examples:Given “abcabcbb”, the answer is “abc”, which the length is 3原创 2016-09-13 20:17:10 · 415 阅读 · 0 评论 -
LeetCodeOJ——2.Add Two Numbers
Add Two NumbersYou 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 retur原创 2016-09-13 19:44:27 · 454 阅读 · 0 评论 -
LeetCodeOJ——9. Palindrome Number
Palindrome NumberDetermine whether an integer is a palindrome. Do this without extra space.解题思路:由于不能有额外的空间,所以可以参考上面的第7题倒转数字,根据回文的性质,倒转后的数字=原数字,注意倒转过程中不要使用额外的空间(除了必要的res)。代码如下: bool isPalindrome(int原创 2016-09-13 21:01:41 · 359 阅读 · 0 评论