https://hack.codingblocks.com/contests/c/512/504
#include
using namespace std;
int main(){
int n,k;
cin >> n >> k ;
int arr[1000000];
for(int i=0; i<n ;i++){
cin >> arr[i];
}
int cur=0;
int setmax=0;
for(int i=0 ;i<=n-k ;i++){ // for transversing till n-k and i++
for(cur=i ;cur<=k ;cur++){ //starting from i and transversing till k subarray
setmax=max(arr[cur],arr[cur+1]);
setmax=max(setmax,arr[cur+2]);
}
}
cout << setmax << endl ;
return 0;
}
where are the problem in this answer
or i have approched in the wrong way