随笔分类 - 2 Leetcode
摘要:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpo...
阅读全文
摘要: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 req...
阅读全文
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.这题和sort list等题都比较相似,需要先用快慢指针的方法找到链表的中点,然后...
阅读全文
摘要:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complet...
阅读全文
摘要:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers....
阅读全文
摘要: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 ...
阅读全文
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the...
阅读全文
摘要:参考:http://www.cppblog.com/wicbnu/archive/2013/03/18/198565.html我太喜欢用dfs和回溯法了,但是这些暴力的方法加上剪枝之后复杂度依然是很高,显然不能达到题目的要求。这个时候应该考虑动态规划,并且要复杂度尽量接近O(n^2)的算法。下面这个...
阅读全文
摘要:Given a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in that surrounded region...
阅读全文
摘要:http://blog.csdn.net/abcbc/article/details/8943485具体的题目描述为:Givennnon-negative integers representing the histogram's bar height where the width of each...
阅读全文

浙公网安备 33010602011771号