- Arrays, frequency-counting, Mathematical, Searching

Generate an array consisting of most frequent greater elements present on the right side of each array element

#include using namespace std;  void findArray(int arr[], int n){        vector v;          for (int i = 0; i < n; i++) {                          int ans = -1, old_c = 0;                  for (int j = i + 1; j < n; j++) {              if (arr[j] > arr[i]) {                                                  int curr_c                    = count(&arr[j], &arr[n], arr[j]);                                  if (curr_c == old_c) {                                                              if (arr[j] < ans)                        ans = arr[j];                }                                                  if (curr_c > old_c) {                    ans = arr[j];                    old_c = curr_c;                }            }        }                  v.push_back(ans);    }          for (int i = 0; i < v.size(); i++)        cout