Occurrence Game Problem Code: ITGUY13

This is the question

and this is the code

#include
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl “\n”
#define input for(int i=0;i<n;i++)cin>>arr[i];
typedef long long int ll;

using namespace std;

int main() {
IOS;
// your code goes here
ll t;
cin>>t;
while(t–>0)
{
ll n,k;
cin>>k>>n;
ll arr[n+1];
for(int i=1;i<n;i++)cin>>arr[i];
ll start, end;
for(int i = 1; i<=n;i++)
{
if(arr[i]==k){
start = i;
}
}

      for (int i = n; i >= 1; i--)
      {
          if(arr[i]==k){
            end = i;  
          }
            
       }



    if(start == end)
    {
        cout<<"-1"<<endl;   
    }
    else
    {
        cout<<start<<" "<<end<<endl;   
    }
}



return 0;

}

help anyone dont know whats going wrong here

take inputs of all the N elements (check the input for loop ) and break the loops whenever you find the element at start or end index or( you can print them in reverse order while printing) and also consider the case where there is no element in the array with the value equals to K

Hey, I saw your solution can you please explain to me why u took to start and end as -1.
and why you are printing end first and start at the last.