原题链接: "https://leetcode.com/problems/maximum depth of binary tree/description/" 这道题目级别为“Easy”,也确实是简单! 不废话,直接使用递归实现深度优先搜索即可: ...
分类:
其他好文 时间:
2018-03-10 14:07:02
阅读次数:
130
问题描述: 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 ...
分类:
编程语言 时间:
2018-03-09 20:38:16
阅读次数:
246
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 comple ...
分类:
其他好文 时间:
2018-03-09 10:42:17
阅读次数:
225
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 comple ...
分类:
其他好文 时间:
2018-03-09 10:37:18
阅读次数:
193
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 comple ...
分类:
其他好文 时间:
2018-03-09 10:37:05
阅读次数:
141
问题链接 "Leetcode 516" 题目解析 求最长回文子序列。 解题思路 子序列和子串有区别的,子序列不需要连续,相对位置递增即可。 动态规划。对于任意字符串,如果头尾字符相同,那么字符串的最长回文子序列等于去掉首尾的字符串的最长回文子序列加上首尾;如果首尾字符不同,则最长子序列等于去掉头的字 ...
分类:
其他好文 时间:
2018-03-08 17:27:40
阅读次数:
122
问题链接 "Leetcode 647" 题目解析 计算字符串的回文子串数。 解题思路 一个小问题,子串(Substring)、子数组(Subarray)和子序列(Subsequence)的区别:子串和子数组是等同的,特点是 连续的 ,比如[1,2,3]的子串有(1), (2), (3), (1,2) ...
分类:
其他好文 时间:
2018-03-08 14:09:37
阅读次数:
184
[抄题]: 找出一个序列中乘积最大的连续子序列(至少包含一个数)。 比如, 序列 [2,3,-2,4] 中乘积最大的子序列为 [2,3] ,其乘积为6。 [暴力解法]: 时间分析:每次j循环时都要再循环i找起点,直接用global[i - 1]存起来表示前i个元素,就不用找(且只存到i - 1) 空 ...
分类:
其他好文 时间:
2018-03-07 00:43:21
阅读次数:
174
问题描写叙述: 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 ...
分类:
其他好文 时间:
2018-03-06 14:43:19
阅读次数:
149
题目描述:Maximum Tape Utilization Ratio Tags: 贪婪策略 设有n 个程序{1,2,…, n }要存放在长度为L的磁带上。程序i存放在磁带上的长度是li ,1 < = i < = n。 程序存储问题要求确定这n 个程序在磁带上的一个存储方案,使得能够在磁带上存储尽可 ...
分类:
其他好文 时间:
2018-03-04 19:07:09
阅读次数:
353