Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Find maximum number in an array using recursion.
int max_in_array(vector<int> nums, int start_index, int end_index) {
if (start_index == end_index) {
return nums[start_index];
}
int maximum = max_in_array(nums, start_index+1, end_index);
return max(nums[start_index], maximum);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.