Can Anyone help me my code failing this test case
1
6
2 2 1 1 1 2
output->>>1 (My code)
Correct solution output ->>>>0
all other test cases are matched.
I tried a lot to find where I am failing but I am not able to find the exact cause please help me.
thanks in advance
this is my code:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll t;
cin >> t;
while (t--)
{
vector<ll int>::iterator it;
vector<ll int> v;
ll int n, i, index, k = 0, bo, count = 0, s;
cin >> n;
ll int z;
for (ll i = 0; i < n; i++)
{
cin >> z;
v.push_back(z);
}
s = *max_element(v.begin(), v.end());
for (i = 0; i < v.size(); i++)
{
vector<ll int> new_;
new_ = v;
rotate(new_.begin(), new_.begin() + k, new_.end());
it = find(new_.begin(), new_.end(), s);
bo = it - new_.begin();
if (bo >= (new_.size() / 2))
{
count++;
}
k++;
}
cout << count << endl;
k = 0;
}
}