算法
dike1993
这个作者很懒,什么都没留下…
展开
-
算法:LeetCode240
题目Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted in ascending from left to right. Integers i原创 2017-03-05 10:18:06 · 311 阅读 · 0 评论 -
leetcode 522. Longest Uncommon Subsequence II
一。题目Given a list of strings, you need to find the longest uncommon subsequence among them. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this s原创 2017-06-01 13:12:50 · 622 阅读 · 0 评论 -
leetcode583. Delete Operation for Two Strings
题目Given two words word1 and word2, find the minimum number of steps required to makeword1 and word2 the same, where in each step you can delete one character in either string.Example 1:Inp原创 2017-05-21 13:17:03 · 351 阅读 · 0 评论 -
leetcode 151. Reverse Words in a String
1.题目Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".2.思路可以考虑先对整个字符串反转,然后对其中的每个word反转,或者倒过来,先对每个word反转,然后对整个字符串反转原创 2017-06-01 13:48:11 · 217 阅读 · 0 评论 -
leetcode 96. Unique Binary Search Trees
1.题目Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1原创 2017-06-03 10:26:27 · 167 阅读 · 0 评论 -
leetcode 106. Construct Binary Tree from Inorder and Postorder Traversal
1.题目Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree2.思路递归.每次从后续遍历最后得到root,然后根据前序分割left tree和right tr原创 2017-06-03 11:46:40 · 171 阅读 · 0 评论 -
算法概论课后8.9
题目:给定一组集合{S1,S2,S3,…,Sn}和预算b,求一个集合H,其中H和所有Si相交且H的规模不超过b,前提是这个集合存在。求证该问题是NP完全问题 证明假设有一个图G(V,E),则把该图的每一条边对应一个集合Si,边上的两个点即该集合的元素,即每个集合有两个元素,如S1={v1,v2},这样一来,就能构造出|E|个集合。求图G的最小顶点覆盖问题,可以转化成求这|E|个集合原创 2017-06-21 11:50:06 · 233 阅读 · 0 评论 -
leetcode 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 length is 3.Given "bbbbb", the answer is "b"原创 2017-06-23 11:41:34 · 217 阅读 · 0 评论 -
leetcode 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 legibility)P A H NA P L原创 2017-06-24 10:44:11 · 212 阅读 · 0 评论 -
leetcode 17. Letter Combinations of a Phone Number
1.题目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:Digi原创 2017-05-27 21:21:33 · 146 阅读 · 0 评论 -
leetcode55. 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 a原创 2017-05-08 17:55:55 · 174 阅读 · 0 评论 -
算法:LeetCode215
题目215 . Kth Largest Element in an ArrayFind the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example, Given [原创 2017-02-26 20:36:52 · 305 阅读 · 0 评论 -
算法:LeetCode207 Course Schedule
题目There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pai原创 2017-03-19 23:57:46 · 263 阅读 · 0 评论 -
leetcode523. Continuous Subarray Sum
题目Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to the multiple of k, that is, sums up to原创 2017-04-09 11:46:38 · 248 阅读 · 0 评论 -
算法:402. Remove K Digits
题目Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible.Note:The length of num is less than 10002 and will be ≥ k.Th原创 2017-03-25 12:05:48 · 266 阅读 · 0 评论 -
算法:LeetCode5. 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.Ex原创 2017-04-02 16:57:15 · 308 阅读 · 0 评论 -
leetcode322. Coin Change
题目You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money原创 2017-04-15 17:03:07 · 173 阅读 · 0 评论 -
leetcode392. Is Subsequence
题目Given a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) string,原创 2017-05-15 13:28:35 · 167 阅读 · 0 评论 -
leetcode516. Longest Palindromic Subsequence
题目Given a string s, find the longest palindromic subsequence’s length in s. You may assume that the maximum length of s is 1000.Example 1: Input:“bbbab”Output:4One possible longest palindromic subsequ原创 2017-04-24 20:00:32 · 381 阅读 · 0 评论 -
leetcode8. 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 the possible inpu原创 2017-06-25 11:49:29 · 273 阅读 · 0 评论