Snippets Collections
int low=0;
          int high=0;
          queue<int>que;
          vector<long long>V;
          while(low<N && high<N)
          {
              if(A[high]<0)
              {
                  que.push(A[high]);
              }
              if(high-low+1==k)
              {
                  if(que.size()==0)
                  {
                      V.push_back(0);
                  }
                  else
                  {
                      V.push_back(que.front());
                  }
              }
              else if(high-low+1>k)
              {
                  while(high-low+1>k)
                  {
                      if(A[low]==que.front())
                      {
                          que.pop();
                      }
                      low++;
                  }
                  if(high-low+1==k)
                  {
                      if(que.size()==0)
                  {
                      V.push_back(0);
                  }
                  else
                  {
                      V.push_back(que.front());
                  }
                      
                  }
              }
              high++;
          }
          return V;
star

Sat Mar 23 2024 07:05:44 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/problems/first-negative-integer-in-every-window-of-size-k3345/1

#sliding

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension