leetcode题解
文章平均质量分 81
flyzhying
学无止境
展开
-
[leetcode] 1. Two Sum
1. Two Sum暴力算法哈希表原创 2017-12-20 10:54:00 · 126 阅读 · 0 评论 -
[LeetCode] 15. 3Sum
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 solutio原创 2018-02-07 09:59:56 · 101 阅读 · 0 评论 -
[LeetCode] 5. Longest Palindromic Substring
5. Longest Palindromic Substring中心点扩张Manacher 算法题目Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example: Input: “b原创 2018-01-25 17:05:50 · 112 阅读 · 0 评论 -
[LeetCode] 14. Longest Common Prefix
14. Longest Common Prefix暴力算法题目Write a function to find the longest common prefix string amongst an array of strings.思路暴力遍历以第一个字符串为模板逐一进行比较,直接获得结果。复杂性分析:时间复杂度:O(n*m).空间复杂度:O(1).原创 2018-01-31 22:52:54 · 109 阅读 · 0 评论 -
[LeetCode] 13. Roman to Integer
13. Roman to Integer罗马数字规则题目Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.思路罗马数字规则 基本表达:I = 1; V = 5; X = 10; L = 50;原创 2018-01-31 20:52:59 · 97 阅读 · 0 评论 -
[LeetCode] 12. Integer to Roman
12. Integer to Roman罗马数字规则题目Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.思路罗马数字规则 基本表达:I = 1; V = 5; X = 10; L = 50; C =原创 2018-01-31 19:51:30 · 132 阅读 · 0 评论 -
[LeetCode] 11. Container With Most Water
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原创 2018-01-31 18:05:22 · 108 阅读 · 0 评论 -
[LeetCode] 10. Regular Expression Matching
10. Regular Expression Matching递归动态规划题目Implement regular expression matching with support for '.' and '*'. ‘.’ Matches any single character. ‘*’ Matches zero or more of the precedi原创 2018-01-31 17:06:33 · 95 阅读 · 0 评论 -
[LeetCode] 9. Palindrome Number
9. Palindrome Number回文数字题目Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of co原创 2018-01-31 10:43:31 · 97 阅读 · 0 评论 -
[LeetCode] 8. String to Integer (atoi)
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 as原创 2018-01-31 10:11:04 · 110 阅读 · 0 评论 -
[LeetCode] 7. Reverse Integer
7. Reverse Integer溢出检查题目Given a 32-bit signed integer, reverse digits of an integer.Example 1: Input: 123 Output: 321Example 2: Input: -123 Output: -321Example 3:原创 2018-01-30 20:16:36 · 118 阅读 · 0 评论 -
[LeetCode] 4. Median of Two Sorted Arrays
4. Median of Two Sorted Arrays暴力算法二分查找题目There 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原创 2018-01-22 19:31:23 · 113 阅读 · 0 评论 -
[LeetCode] 6. ZigZag Conversion
6. ZigZag Conversion找规律题目The 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 le原创 2018-01-30 11:30:09 · 136 阅读 · 0 评论 -
[LeetCode] 3. Longest Substring Without Repeating Characters
3. Longest Substring Without Repeating Characters暴力算法哈希表原创 2017-12-22 22:05:09 · 172 阅读 · 0 评论 -
[LeetCode] 2. Add Two Numbers
2. Add Two Numbers反序求和 链表操作原创 2017-12-21 10:55:17 · 163 阅读 · 0 评论 -
[LeetCode] 16. 3Sum Closest
16. 3Sum Closest转化思想头尾指针题目思路转化思想 将问题转化为求三数和为target的问题。复杂性分析: 时间复杂度:O(n^2).空间复杂度:O(1).题解class Solution {public: int threeSumClosest(vectorint>& nums, int target) {原创 2018-02-07 11:37:56 · 109 阅读 · 0 评论