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 a...
阅读全文
posted @
2017-07-01 10:49
lantx
阅读(475)
推荐(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 ...
阅读全文
posted @
2017-06-12 17:07
lantx
阅读(200)
推荐(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...
阅读全文
posted @
2017-06-12 16:00
lantx
阅读(116)
推荐(0)
Leetcode 147. Insertion Sort List
摘要:题目:Sort a linked list using insertion sort.思路: 使用一个指针p指向未排好序的链表的第一个结点,在排序好的部分中找到找第一个大于等于q的前驱结点,将p对应的结点插入到正确位置,p重新指向未排好序的链表的第一个结点。直到链表完成排序好。 代码...
阅读全文
posted @
2017-06-12 15:44
lantx
阅读(156)
推荐(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 t...
阅读全文
posted @
2017-06-12 15:04
lantx
阅读(113)
推荐(0)
Leetcode 14. Longest Common Prefix
摘要:题目:Write a function to find the longest common prefix string amongst an array of strings.思路:先定最长的公共前缀为第一个字符串, 然后依次将这个与剩余的字符串作比较,得出最小的长度 即为最长公共...
阅读全文
posted @
2017-06-12 14:31
lantx
阅读(89)
推荐(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”Ou...
阅读全文
posted @
2017-06-12 13:53
lantx
阅读(141)
推荐(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 s...
阅读全文
posted @
2017-05-11 00:34
lantx
阅读(121)
推荐(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 ...
阅读全文
posted @
2017-05-10 11:54
lantx
阅读(117)
推荐(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 co...
阅读全文
posted @
2017-05-10 11:33
lantx
阅读(121)
推荐(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?思路:思路就是先进行对角...
阅读全文
posted @
2017-05-10 10:33
lantx
阅读(111)
推荐(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 数组保存 十进制数字 与罗马数字...
阅读全文
posted @
2017-05-10 10:06
lantx
阅读(102)
推荐(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 cos...
阅读全文
posted @
2017-03-30 14:46
lantx
阅读(101)
推荐(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 Acc...
阅读全文
posted @
2017-03-30 14:29
lantx
阅读(135)
推荐(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...
阅读全文
posted @
2017-03-15 20:44
lantx
阅读(101)
推荐(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 rain
阅读全文
posted @
2017-02-27 15:01
lantx
阅读(158)
推荐(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 algor
阅读全文
posted @
2017-02-27 13:51
lantx
阅读(138)
推荐(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
阅读全文
posted @
2017-02-25 21:01
lantx
阅读(116)
推荐(0)
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. Exampl
阅读全文
posted @
2017-02-23 16:54
lantx
阅读(99)
推荐(0)