码迷,mamicode.com
首页 >  
搜索关键字:maximum repetition s    ( 4177个结果
RMQ(range minimum/maximum query)即查询区间最大最小值。
对于求区间最大最小值,我们自然而然就想到了一个O(n)时间复杂度的算法,但是如果询问有很多呢?这样必然超时。当然我们可以用线段树来解,使得每一次查询的时间降到log(n),但是对于RMQ算法,只要我们做了些预处理,之后的查询我们仅需要O(1)的时间。Sparse_Table算法是解决RMQ问题的一类...
分类:其他好文   时间:2014-11-19 23:55:43    阅读次数:250
Maximum Depth of Binary Tree 树的最大深度
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le...
分类:其他好文   时间:2014-11-19 23:46:55    阅读次数:247
LeetCode:Best Time to Buy and Sell Stock II
题目描述: 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 complete as many transactions as you like ...
分类:其他好文   时间:2014-11-19 22:18:52    阅读次数:225
Maximum Product Subarray
Maximum Product SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given...
分类:其他好文   时间:2014-11-19 21:46:14    阅读次数:152
[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,?1,2,1,?5,4], the contiguous subarray [4,?1,...
分类:其他好文   时间:2014-11-19 20:40:18    阅读次数:125
CodeForces 484B Maximum Value
题意: a序列有n(2*10^5)个数字  问在a[i]>=a[j]的情况下  a[i]%a[j]的最大值是多少 思路: 感觉是一道挺乱来的题…… 我们可以将ans表示为a[i]-k*a[j]  这样我们枚举k只要知道比k*a[j]大但是不到(k+1)*a[j]的值就好了  考虑到a[i]只要10^6大  因此可以用一个last数组记录小于等于i的数组中的数字  因此只要拿出last[(k...
分类:其他好文   时间:2014-11-19 20:37:04    阅读次数:167
【Leetcode】经典的Jump Game in JAVA
Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine i...
分类:编程语言   时间:2014-11-19 18:51:35    阅读次数:226
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,?1,2,1,...
分类:其他好文   时间:2014-11-19 17:48:30    阅读次数:115
LeetCode——Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine i...
分类:其他好文   时间:2014-11-19 12:35:24    阅读次数:130
[leetcode]Jump Game
问题描述: Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Dete...
分类:其他好文   时间:2014-11-19 11:16:51    阅读次数:145
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!