Queue Flashcards

1
Q

First negative integer in every window of size k ,

time: O(n) , Space : O(k) using deque

A

define ll long long

#include 
using namespace std;
int main() {
	ll t;
	cin>>t;
	while(t--)
	{
	    ll n,k,i,j;
	    cin>>n;
	    ll a[n];
	    deque d;
	    for(i=0;i>a[i];
	    }
	    cin>>k;
	    for(i=0;i
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Maximum of all subarrays of size k,
time : O(n)
space : O(k)

A

define ll long long

#include 
using namespace std;
ll findmax(ll a[],ll n,ll j)
{
    ll maxm = INT_MIN;
    for(ll i=j;i>t;
	while(t--)
	{
	    ll n,k,i;
	    cin>>n>>k;
	    ll a[n];
	    for(i=0;i>a[i];
	    }
	    queue q;
	    ll maxm = INT_MIN;
	    for(i=0;i
How well did you know this?
1
Not at all
2
3
4
5
Perfectly