Skip to content

Instantly share code, notes, and snippets.

@pranavsuresh7
Created March 18, 2020 13:51
Show Gist options
  • Save pranavsuresh7/b524f4eb2c15567a8cd713a64b8014bc to your computer and use it in GitHub Desktop.
Save pranavsuresh7/b524f4eb2c15567a8cd713a64b8014bc to your computer and use it in GitHub Desktop.
naive way for maximum value
#include<bits/stdc++.h>
using namespace std;
int maxRange(int *arr,int llimit,int hlimit){
int max_value = arr[llimit];
for(int i=llimit;i<hlimit;i++){
if(max_value<arr[i]) max_value = arr[i];
}
return max_value;
}
int main(){
int arr_value[100000];
int arr[] = {-1,2,-1,10,30,4};
int testCase = 1;
while(testCase--){
int start,end;
cin >> start >> end;
cout << maxRange(arr,start-1,end) << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment