![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
文章平均质量分 82
「已注销」
学海无涯,回头是岸
展开
-
LeetCode 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 should be O(log (m+n)).思路:本题要求出两个有序数组的中位原创 2017-02-25 22:11:51 · 875 阅读 · 0 评论 -
Sicily 1936. Knight Moves
题目:ConstraintsTime Limit: 1 secs, Memory Limit: 32 MB DescriptionA friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of k原创 2017-06-02 15:28:27 · 301 阅读 · 0 评论 -
Leetcode 516. 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.思路:动态规划。设一个n行n列的dp数组,n为s的长度。dp[i][j]表示字符串i到j下标所构成的子串中最长回文子序列的长度。最原创 2017-05-09 18:49:12 · 175 阅读 · 0 评论 -
Leetcode 121. Best Time to Buy and Sell Stock
题目:Say you have an array for which the ith element is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the s原创 2017-05-09 16:59:26 · 176 阅读 · 0 评论 -
Leetcode 312. Burst Balloons
题目:Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by arraynums. You are asked to burst all the balloons. If the you burst ballooni you will ge原创 2017-05-09 16:45:12 · 260 阅读 · 0 评论 -
Leetcode 97. Interleaving String
题目:Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbba原创 2017-04-22 21:35:44 · 212 阅读 · 0 评论 -
Leetcode 32. Longest Valid Parentheses
题目:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()原创 2017-04-14 20:11:26 · 221 阅读 · 0 评论 -
Leetcode 337. House Robber III
题目:The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After原创 2017-03-16 18:25:11 · 226 阅读 · 0 评论 -
Leetcode 124. Binary Tree Maximum Path Sum
题目:Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections.原创 2017-03-15 17:03:12 · 431 阅读 · 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-03-31 19:39:12 · 248 阅读 · 0 评论 -
Leetcode 330. Patching Array
题目:Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n]inclusive can be formed by the sum of some elements in the a原创 2017-03-31 11:11:09 · 199 阅读 · 0 评论 -
Leetcode 142. Linked List Cycle II
题目:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Note: Do not modify the linked list.思路:链表从头往后访问,每访问一个节点就标记为已访问。如果访问到某个节点时发现其已经被访问过,则说明有环存在,原创 2017-03-22 14:29:13 · 192 阅读 · 0 评论 -
Leetcode 407. Trapping Rain Water II
题目:Given an m x n matrix of positive integers representing the height of each unit cell in a 2D elevation map, compute the volume of water it is able to trap after raining.Note:Both m and n ar原创 2017-03-22 14:28:40 · 200 阅读 · 0 评论 -
Leetcode 459. Repeated Substring Pattern
题目:Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercas原创 2017-03-06 21:34:09 · 264 阅读 · 0 评论 -
LeetCode 53. Maximum Subarrays
题目:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarray [4原创 2017-02-27 11:31:47 · 183 阅读 · 0 评论 -
Leetcode 451. Sort Characters By Frequency
题目:Given a string, sort it in decreasing order based on the frequency of characters.Example 1:Input:"tree"Output:"eert"Explanation:'e' appears twice while 'r' and 't' both appear once.原创 2017-06-13 17:40:06 · 302 阅读 · 0 评论