I tried to rectify my code, but still, t is showing time-limit- exceeded.
Here Is The Code :
#include
using namespace std;
int main()
{
int n,i,k,j,max;
cin>>n;
int arr[n];
for(i=0;i<n;i++)
{
cin>>arr[i];
}
cin>>k;
for (int i = 0; i <= n - k; i++)
{
max = arr[i];
for (j = 1; j < k; j++)
{
if (arr[i + j] > max)
{
max = arr[i + j];
}
}
cout << max << " ";
}
return 0;
}