![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Leetcode
文章平均质量分 72
lantx_SYSU
人类因梦想而伟大!
展开
-
Leetcode 3. Longest Substring Without Repeating Characters
题目: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 le原创 2017-02-23 16:54:17 · 203 阅读 · 0 评论 -
Leetcode 300. Longest Increasing Subsequence
题目:Given an unsorted array of integers, find the length of longest increasing subsequence.For example, Given [10, 9, 2, 5, 3, 7, 101, 18], The longest increasing subsequence is [2, 3, 7, 101], theref原创 2017-06-12 16:00:20 · 223 阅读 · 0 评论 -
Leetcode 147. Insertion Sort List
题目:Sort a linked list using insertion sort.思路: 使用一个指针p指向未排好序的链表的第一个结点,在排序好的部分中找到找第一个大于等于q的前驱结点,将p对应的结点插入到正确位置,p重新指向未排好序的链表的第一个结点。直到链表完成排序好。 代码实现代码:/** * Definition for singly-linked list. * struct Li原创 2017-06-12 15:44:24 · 163 阅读 · 0 评论 -
Leetcode 17. 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:Digit string “23原创 2017-06-12 15:04:57 · 178 阅读 · 0 评论 -
Leetcode 14. Longest Common Prefix
题目:Write a function to find the longest common prefix string amongst an array of strings.思路:先定最长的公共前缀为第一个字符串, 然后依次将这个与剩余的字符串作比较,得出最小的长度 即为最长公共前缀的长度,然后从第一个字符串上面截取就可以代码:class Solution {public: str原创 2017-06-12 14:31:17 · 163 阅读 · 0 评论 -
Leetcode 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.Example:Input: “babad”Output: “bab”Note: “aba” is also a valid answer. Example:Inp原创 2017-06-12 13:53:56 · 155 阅读 · 0 评论 -
NPC问题证明题
STINGY SAT is the following problem: given a set of clauses (each a disjunction of literals) and an integer k, find a satisfying assignment in which at most k variables are true, if such an assignment原创 2017-07-01 10:49:53 · 535 阅读 · 0 评论 -
Leetcode 135. Candy
题目:There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at原创 2017-05-10 11:54:28 · 144 阅读 · 0 评论 -
Leetcode 134. Gas Station
题目:There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from stat原创 2017-05-10 11:33:36 · 180 阅读 · 0 评论 -
Leetcode 48 Rotate Image
题目:You 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?思路:思路就是先进行对角翻转,然后作左右对称1 2 3原创 2017-05-10 10:33:00 · 172 阅读 · 0 评论 -
Leetcode 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.思路:1. 构造values,和numerals 数组保存 十进制数字 与罗马数字的对应2. 遍历values数组,从最大开始,如果num比当前比较的原创 2017-05-10 10:06:31 · 217 阅读 · 0 评论 -
Leetcode 44. Wildcard Matching
题目:'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover the entire input string (not partial).The function prototyp原创 2017-05-11 00:34:25 · 147 阅读 · 0 评论 -
Leetcode 134 gas-station
题目:There are N gas stations along a circular route, where the amount of gas at station i isgas[i].You have a car with an unlimited gas tank and it costscost[i]of gas to travel from station i原创 2017-03-30 14:46:40 · 221 阅读 · 0 评论 -
Leetcode 62. Unique Paths
题目:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to rea原创 2017-03-15 20:44:25 · 190 阅读 · 0 评论 -
Leetcode 56. Merge Intervals
题目:Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].Total Accepted: 113975Total Submissions:原创 2017-03-30 14:29:00 · 202 阅读 · 0 评论 -
Leetcode 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 no原创 2017-02-25 21:01:54 · 194 阅读 · 0 评论 -
Leetcode 42. Trapping Rain Water
题目:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3原创 2017-02-27 15:01:00 · 166 阅读 · 0 评论 -
Leetcode 41. First Missing Positive
题目:Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses原创 2017-02-27 13:51:41 · 145 阅读 · 0 评论 -
Leetcode 55. Jump Game
题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you原创 2017-06-12 17:07:48 · 169 阅读 · 0 评论