Maximum Fixed Point (Value equal to index) in a given Array

Given an array arr[] of size N, the task is to find the maximum index i such that arr[i] is equal to i. If there is no such index in the array arr[] then print -1.Examples:Input: arr[ ] = {-10, -5, 0, 3, 7}Output: 3Explanation: Only for i=3, arr[3] = 3Input: arr[ ] = {0, 2, 5, 8, 4}Output: 4Approach: Follow the steps below to solve this problem:Iterate in the range [N-1, 0] using the variable i: If the current element is equal to i, then print i and return.If there is no such index, then print -1.Below is the implementation of the above approach:C++#include using namespace std;  void findLargestIndex(int arr[], int n){              for (int i = n – 1; i >= 0; i–) {                  if (arr[i] == i) {            cout