Source Code
#include <iostream>
#include "algorithm"
#include "cmath"
using namespace std;
int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int tt;
    cin >> tt;
    while (tt--) {
        int size;
        cin >> size;
        long long arr[size];
        for (int i = 0; i < size; i++) {
            cin >> arr[i];
        }
        bool not_equal = false;
        bool equal = false;
        int j;
        for (j = 0; j < size; j++) {
            int max = arr[j];
            for (int k = j + 1; k < size; k++) {
                if (max == arr[k]) {
                    not_equal = true;

                }if (max != arr[k]) {
                    equal = true;
                }

            }

        }
        if (not_equal)
            cout << j-1 << endl;
        if (equal)
            cout << j << endl;
        else
            cout << -1 << endl;
    }
}
Copy
Proud Competitors YoussefAbdelhakem
GNU G++17
2 ms
240 KB
Wrong Answer