题目:二叉树的最大深度给定一个二叉树,找出其最大深度。二叉树的深度为根节点到最远叶子节点的距离。样例给出一棵如下的二叉树: 1 / \ 2 3 / \ 4 5这个二叉树的最大深度为3.解题:递归方式求树的深度,记住考研时候考过这一题Java程序:/** * Definition of...
分类:
其他好文 时间:
2015-10-10 16:46:07
阅读次数:
228
这篇文章讲无权二分图(unweighted bipartite graph)的最大匹配(maximum matching)和完美匹配(perfect matching),以及用于求解匹配的匈牙利算法(Hungarian Algorithm);不讲带权二分图的最佳匹配。二分图:简单来说,如果图中点可以...
分类:
编程语言 时间:
2015-10-10 11:54:16
阅读次数:
132
Description:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You ma...
分类:
其他好文 时间:
2015-10-08 19:53:47
阅读次数:
130
页面在移动设备中,展现方式,是否能缩放需要设置解释说明:width - viewport的宽度 height - viewport的高度initial-scale - 初始的缩放比例minimum-scale - 允许用户缩放到的最小比例maximum-scale - 允许用户缩放到的最大比例use...
分类:
Web程序 时间:
2015-10-08 14:41:02
阅读次数:
148
题目: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,?1,2...
分类:
其他好文 时间:
2015-10-08 12:59:14
阅读次数:
193
二叉树最大深度的递归实现。/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNo...
分类:
其他好文 时间:
2015-10-07 17:19:10
阅读次数:
131
控制显示区域各种属性: width - viewport的宽度height – viewport的高度initial-scale - 初始的缩放比例minimum-scale - 允许用户缩放到的最小比例maximum-scale – 允许用户缩放...
分类:
移动开发 时间:
2015-10-07 16:00:18
阅读次数:
207
最大子数组分析O(n)对于一个数组,数组中有正有负,求最大子数组1, 该数组只可能从一个正数开始2, 在从这个元素p1挨个求和,记录这个过程中的最大和3, 如果这个和加到元素n1等于0了,那么整个数组的最大子数组和,要么就是上面中出现过的最大和,要么就在此n1之后的子数组中,不可能是从p1到n1之间...
分类:
其他好文 时间:
2015-10-07 12:08:36
阅读次数:
186
题目: Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique lo...
分类:
其他好文 时间:
2015-10-06 22:12:48
阅读次数:
479
题目: Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longe....
分类:
其他好文 时间:
2015-10-04 17:09:04
阅读次数:
165