概述 RMQ(Range Minimum/Maximum Query),即区间最值查询,是指这样一个问题:对于长度为n的数列A,回答若干询问RMQ(A,i,j)(i,j<=n),返回数列A中下标在i,j之间的最小/大值。这两个问题是在实际应用中经常遇到的问题,下面介绍一下解决这两种问题的比较高效的算 ...
分类:
编程语言 时间:
2016-04-26 14:05:38
阅读次数:
223
Problem B Problem Description A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X ...
分类:
其他好文 时间:
2016-04-26 10:58:03
阅读次数:
165
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 l ...
分类:
其他好文 时间:
2016-04-25 20:55:00
阅读次数:
129
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 roo ...
分类:
其他好文 时间:
2016-04-25 00:37:34
阅读次数:
142
正在看《算法设计与分析》的动规3.4 ,因此找了这道题来写。 ...
分类:
其他好文 时间:
2016-04-24 23:01:35
阅读次数:
253
描述 分析 尺取法. 定义区间左右端点l和r.l从1开始循环到n,r向后移动,直到区间和 >=s,此时为左端点为l时的最短长度.对于左端点为l+1的情况,使得 区间和>s的右端点一定>=r,就让r右移直到满足条件.如果r=n仍无法 满足,那对于之后的l都无法满足,即可break. 此题用二分O(nl ...
分类:
其他好文 时间:
2016-04-22 23:55:18
阅读次数:
185
Longest Palindromic Substring 最长回文子串 Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 100 ...
分类:
其他好文 时间:
2016-04-22 18:25:01
阅读次数:
147
Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array. Formally the function should: Your algorithm ...
分类:
其他好文 时间:
2016-04-22 16:01:34
阅读次数:
141