C++
文章平均质量分 54
取个名怎么就这么难
并没有什么介绍的
展开
-
K个值求和计算
转自烟客旅人 sigmainfy — tech-wonderland.net:http://tech-wonderland.net/blog/summary-of-ksum-problems.html Summary for LeetCode 2Sum, 3Sum, 4Sum, K Sum Overview I summarize vario转载 2015-10-11 20:24:09 · 1817 阅读 · 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 · 192 阅读 · 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 · 227 阅读 · 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 · 349 阅读 · 0 评论 -
leetcode Unique Binary Search Trees II 答案详解
Given n, generate all structurally unique BST'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 · 376 阅读 · 0 评论 -
leetcode Minimum Window Substring答案解析
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example, S = "ADOBECODEBANC" T = "ABC" Minimum window is "BANC"原创 2015-12-01 21:11:12 · 417 阅读 · 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 · 244 阅读 · 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 · 324 阅读 · 0 评论 -
[Leetcode] Single Number III
问题描述: Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. For example:转载 2016-04-06 15:50:16 · 319 阅读 · 0 评论