码迷,mamicode.com
首页 >  
搜索关键字:leetcode 19    ( 34993个结果
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-08 21:08:25    阅读次数:407
Leetcode | Sort Colors
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, ...
分类:其他好文   时间:2014-05-07 18:01:05    阅读次数:412
[leetcode] Path sum路径之和
要求给定树,与路径和,判断是否存在从跟到叶子之和为给定值的路径。比如下图中,给定路径之和为22,存在路径,因此返回true;否则返回false. 5 / \ 4 8 / / \ 11...
分类:其他好文   时间:2014-05-07 10:15:46    阅读次数:270
Leetcode | Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 ...
分类:其他好文   时间:2014-05-07 09:36:09    阅读次数:300
LeetCode OJ - Validate Binary Search Tree
验证二叉树是否是查找树,可以通过查看它的中序遍历是否是升序的。下面是AC代码: 1 /** 2 * Given a binary tree, determine if it is a valid binary search tree (BST). 3 * solution : 4...
分类:其他好文   时间:2014-05-07 09:01:45    阅读次数:250
LeetCode::Trapping Rain Water
1、到今天完成39题,还需要不停的加油。今天再分析下装雨水这道题Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water i...
分类:移动开发   时间:2014-05-06 14:08:48    阅读次数:490
LeetCode OJ - Recover Binary Search Tree
这道题要求空间复杂度为O(1),则只能采用Morris Traversal进行中序遍历!!这个了解了之后,难点在于如何定位到两个被交换了的节点?我就被困在这里几个小时!!!(允许我为自己的愚蠢表示下悲伤吧!!!)参考了discuss中前辈的算法,才发现很简单!!!我们只需要这样来看问题,BST的中序...
分类:其他好文   时间:2014-05-06 12:55:19    阅读次数:301
Leetcode: Two Sum
这道题看似简单,其实很坑爹啊,动不动就是Time Limit Exceeded, 比如我下面这段TLE的代码,我感觉方法是对的,但是too naive,算法复杂度到了O(N^2),自然就TLE了而且有一些小语法错误需要注意:for(runner=current+1;;)不能用>;一定所有的case都...
分类:其他好文   时间:2014-05-06 11:31:09    阅读次数:405
Leetcode: Reverse Integer
一次通过,它的spoiler里面的提示有两个:1. 末尾为0的情况,这个考虑到了2.Did you notice that the reversed integer might overflow? Assume the input is a 32-bit integer, then the reve...
分类:其他好文   时间:2014-05-06 11:10:45    阅读次数:356
Leetcode: Palindrome Numbers
尝试用两头分别比较的方法,结果发现无法解决1000021这种问题 1 public class Solution { 2 public boolean isPalindrome(int x) { 3 if(x= 10) { 6 div *= 10; 7...
分类:其他好文   时间:2014-05-06 10:39:40    阅读次数:241
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!