Created
March 18, 2020 13:51
-
-
Save pranavsuresh7/b524f4eb2c15567a8cd713a64b8014bc to your computer and use it in GitHub Desktop.
naive way for maximum value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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