由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 最大增加量的算法
相关主题
大意了,尼玛问个小算法
sliding window面试题有重复元素的全排列,递归算法
请问bloomberg的冷却期是多久, 附面经请教一个算法题
what is the internal implementation of DequeProgramming Interview Exposed, 尽信书则不如无书
感觉leetcode上没有什么“算法题”啊。请教一道算法题目,请高手指点
Onsite面试题几道问个rotated array里面找element的问题
一道面试题。问个facebook 面试题
问一道算法题,find min in the last k elementsMinimum Window Substring (from leetcode)
相关话题的讨论汇总
话题: deque话题: 算法话题: 上界话题: front话题: res
进入JobHunting版参与讨论
1 (共1页)
b****u
发帖数: 1130
1
不是面试题,这里人多就问一下。
就是求 max(x[i]-x[j]), where L>=i-j>=0.
主要问题是上界L,找不到一个有效的算法。没有上界的话可以有O(N)的算法。加上
这个上界似乎可以有个O(NlogL)的算法,但不知道如何搞。
s******g
发帖数: 139
2
用个 deque 就可以了, deque 的front() 是 sliding window中的最小的元素. 扫描数
组, 如果当前元素 大于front(), update res as res = max(res, x[i]-dq.front());
if front() is moving out of the L-sliding window, pop_front(), pop all the
elments in the deque starting from the back() that is no less than x[i],
then push x[i] in the deque.
(e.g. while(!dq.empty()) if(dq.back()>=x[i]) dq.pop_back(); dq.push_back(x[
i]);
Should be O(N) since each element gets in/out the deque only once
r*******g
发帖数: 1335
3
sliding window minimum
nice question
1 (共1页)
进入JobHunting版参与讨论
相关主题
Minimum Window Substring (from leetcode)感觉leetcode上没有什么“算法题”啊。
M大小的数组中选出前N个元素 (如果M和N都很大)Onsite面试题几道
去掉单向链表中的重复元素 with O(n) time and O(1) (转载)一道面试题。
请教个算法题问一道算法题,find min in the last k elements
大意了,尼玛问个小算法
sliding window面试题有重复元素的全排列,递归算法
请问bloomberg的冷却期是多久, 附面经请教一个算法题
what is the internal implementation of DequeProgramming Interview Exposed, 尽信书则不如无书
相关话题的讨论汇总
话题: deque话题: 算法话题: 上界话题: front话题: res