DescriptionAn array of size n ≤ 106 is given to you. There is a sliding window of size k which is moving from the very left of th...
转载 2019-01-05 08:48:00
106阅读
Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two
转载 2019-07-28 03:44:00
87阅读
2评论
Problem DescriptionAn array of size n ≤ 106 is given to yo
原创 2022-08-10 12:48:53
35阅读
Question:A long array A[] is given to you. There is a sliding window of size w which is moving from the very left of the array to the very right. You can only see the w numbers in the window. Each tim
转载 精选 2015-01-19 06:15:56
862阅读
方法1:Time Complexity O(NK) 暂时只有两个Heap的做法,缺点:In this problem, it is necessary to be able remove elements that are not necessarily at the top of the heap
转载 2017-01-24 05:24:00
166阅读
2评论
题目链接:http://leetcode.com/2011/01/sliding-window-maximum.html咳咳,很长时间没有写博客了。各种各样的事情,前段时间又被各种打击。调整了好久,终于状态好多了,SO,步入正轨了。题目分析:其实就是给定一个长度为N的数组,以k为窗口长度,窗口自左向右滑动,求出每一次窗口的最大值。如果用蛮力的话,复杂度是O(KN),因为每一次取出k个元素,都要重新算最大值。其实仔细观察可以发现,每一次窗口的滑动都是从左边出一个数,右边进一个数,这样的操作规则不就是队列的特质么,从一边进,另一边出。这样就把问题转化成求大小为k的队列的最大值,每一次队列出一个、进
转载 2013-09-03 19:47:00
60阅读
2评论
在这里先说一道微软的面试题目———《队列中的最大值》      让你设计一个队列,是其求里面最大值的时间复杂度尽可能的低,但这个
原创 2022-07-18 16:00:14
81阅读
Sliding WindowTime Limit: 12000MSMemory Limit: 65536KTotal Submissions: 26178Accepted: 7738Case Time Limit: 5000MSDescriptionAn array of size n ≤ 106 is given to you. There is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers
原创 2021-07-29 16:21:43
90阅读
单调队列模板题。 #include<iostream>#include<cstdio>#include<cstring>#define maxn 1000050using namespace std;int n,k,num[maxn],ans1[maxn],ans2[maxn];int q1[max
转载 2016-03-14 23:09:00
73阅读
2评论
http://poj.org/problem?id=282
原创 2022-06-16 00:28:24
67阅读
Description An array of size n ≤ 106 is given to you. There is a sliding window of size k which is moving from the very left of the array to the ve
原创 2022-12-07 14:16:29
61阅读
题目链接:https://leetcode.com/problems/sliding-window-maximum/题目: Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only s
原创 2023-07-26 16:40:23
52阅读
单调队列
原创 2023-02-16 06:50:41
83阅读
方法一:Heap时间 O(NlogK) 空间 O(K) maintain a maximum heap, notice PriorityQueue.remove(object o) can remove certain object from our heap. When writting Maxi
转载 2015-12-20 12:25:00
178阅读
2评论
Sliding WindowTime Limit: 12000msMemory Limit: 65536KBThis problem will be judged onPKU. Original ID:282364-bit integer IO format:%lld Java class name...
转载 2015-08-17 22:32:00
22阅读
Sliding Window Time Limit: 12000MS Memory Limit: 65536K Total Submissions: 54824 Accepted: 15777 Case Time Limit: 5000MS Description An array of size
转载 2016-09-02 21:24:00
84阅读
2评论
POJ_2823     这个是在接触了单调队列优化后的第一个题目,其实个人感觉单调队列所作的优化就是维护了一个始终保存当前最优解的队列。     解的合法性是通过队列内各元素的标号的单调性保证的,每次要通过队首删除元素的操作来保证队列内的解是在当前区间内的。     队首元素的最优性则是由队列内元素值的单调性保证的,每次要通过将队尾不比当前待插入的元素更优的元素删除来保证了队首元素的最优性。
转载 2011-11-10 16:28:00
31阅读
2评论
POJ 2823 Sliding Window Description An array of size 6is given to you. There is a sliding window of sizekwhich is moving from the very left of the arr
转载 2020-11-04 15:05:00
73阅读
2评论
Sliding WindowPOJ - 2823An array of sizen≤ 106is given to you. Thnly see theknu...
原创 2023-06-09 14:06:47
48阅读
滑动窗口分固定窗口和可变窗口,解决 atMostK 问题,大量 leetcode 实践。
原创 2023-05-22 10:35:52
78阅读
  • 1
  • 2
  • 3
  • 4
  • 5