码迷,mamicode.com
首页 >  
搜索关键字:leetcode 19    ( 34993个结果
Leetcode:Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 解题想法: 其实判断一个直线上最好的方法是判断斜率。如果在同一直线上,那么直线上一点与其他点的斜率相...
分类:其他好文   时间:2014-05-07 21:13:02    阅读次数:323
LeetCode:Maximum Subarray
题目链接 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,...
分类:其他好文   时间:2014-05-07 16:42:42    阅读次数:287
leetcode第一刷_Best Time to Buy and Sell Stock II
这道题虽然是上一道题的增强,但是反而简单了。可以交易无数次,但是买卖必须成对的出现。 为了简单起见,我用abc三股股票来说明,且忽略掉相等的情况。三个数一共有六种大小关系。注意他们之间的先后顺序是不能乱的。 1. a 2. b 3. a 4. b 5. c 6. c 好的,你已经看出来了,只要当相邻的两个数是后面一个较大时,就之间累计上他们的差,否则,pass。直观一点的表述,只要...
分类:其他好文   时间:2014-05-07 12:33:11    阅读次数:512
leetcode第一刷_Best Time to Buy and Sell Stock III
这道题还是挺难的,属于我前面提到的,给个数组,线性时间找出个什么东西,虽然上面的两个买卖股票也是这类,不过相比之下稚嫩多了。有关至少至多的问题比较烦人,不好想,等再做一些题,可能会发现什么规律。这道题的情况还是比较少的,要么买卖了两次,要么一次。 买卖一次的情况,已经解决过了,现在分析买卖两次的情况。两次买卖之间是没有交叉的,即下一次买之前一定已经卖掉了。最容易想到,穷去分点,每个部分都按照买卖...
分类:其他好文   时间:2014-05-07 11:27:50    阅读次数:331
Leetcode | Subsets I & II
Subsets IGiven a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set m...
分类:其他好文   时间:2014-05-07 11:13:33    阅读次数:299
Leetcode | Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the fol...
分类:其他好文   时间:2014-05-07 02:55:24    阅读次数:377
leetcode题目:Copy List with Random Pointer
题目: A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list. 思路: 主要是深层复制的问题: 本题比较简...
分类:其他好文   时间:2014-05-07 02:44:38    阅读次数:344
Leetcode | Populating Next Right Pointers in Each Node I & II
Populating Next Right Pointers in Each Node IGiven a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLin...
分类:其他好文   时间:2014-05-07 01:34:51    阅读次数:407
leetcode -day9 Candy & Gas Station & Binary Tree Maximum Path Sum
1、 ?? 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 h...
分类:其他好文   时间:2014-05-06 22:41:02    阅读次数:427
LeetCode - Unique Binary Search Trees
题目原文:     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. 题目理解...
分类:其他好文   时间:2014-05-06 22:15:57    阅读次数:415
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!