➤ Problem Link : 1143A. The Doors
✅ C++ Solution :
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i;
cin>>n;
bool arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
if(n==1)
cout<<"1";
else if(n==2)
{
if(arr[0]==arr[1])
cout<<"2";
else
cout<<"1";
}
else
{
for(i=n-2;i>=0 && arr[i]==arr[n-1];i--);
cout<<i+1;
}
}
Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook.
😇Happy Learning!!
