Preview:
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;
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter