![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
取个名怎么就这么难
并没有什么介绍的
展开
-
K个值求和计算
转自烟客旅人 sigmainfy — tech-wonderland.net:http://tech-wonderland.net/blog/summary-of-ksum-problems.htmlSummary for LeetCode 2Sum, 3Sum, 4Sum, K Sum OverviewI summarize vario转载 2015-10-11 20:24:09 · 1812 阅读 · 0 评论 -
leetcode Set Matrix Zeroes 代码解析
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 开辟一个长为m+n的数组标记每一行每一列是否出现0.使用O(1)空间方法:使用原数组第一行和第一列记录0 的位置信息将 0 映射到第一行和第一列,使用col 和row 分别记录第一原创 2015-11-29 12:47:22 · 188 阅读 · 0 评论 -
leetcode Search a 2D Matrix
典型的二叉搜索问题先找到在第几行再找第几个class Solution {public: bool searchMatrix(vector >& matrix, int target) { int fir=0,las=matrix.size()-1,le=0,ri=matrix[0].size()-1; while(fir原创 2015-11-29 13:00:25 · 205 阅读 · 0 评论 -
leetcode Editdistance
leetcode Edit Distance 答案解析 动态规划 Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:原创 2015-11-28 20:39:28 · 243 阅读 · 0 评论 -
Unique Binary Search Trees leetcode答案解析
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. 给一个整数n,求以1~n共能组成多少种二叉搜索树动态规划题,创建一数组ans原创 2015-12-17 21:06:15 · 326 阅读 · 0 评论 -
leetcode Unique Binary Search Trees II 答案详解
Given n, generate all structurally uniqueBST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1原创 2015-12-17 21:17:03 · 350 阅读 · 0 评论 -
leetcode Largest Rectangle in Histogram 代码解析
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width of转载 2015-12-07 16:01:58 · 218 阅读 · 0 评论 -
[Leetcode] Sliding Window Maximum 滑动窗口最大值
Sliding Window MaximumGiven an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each转载 2016-04-05 21:00:18 · 408 阅读 · 0 评论 -
[Leetcode] Ugly Number II
题目描述:Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the转载 2016-04-06 15:20:46 · 303 阅读 · 0 评论