Source Code
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,d;
    cin>>n>>d;
    vector<int> v(n);
    for(int i = 0 ;i < n ;i++)
     cin>>v[i];
    int cnt = ,ans = 0;
    for(int i = 0 ; i < n; i++)
    {
        if(v[i] == d)
         cnt++;
        else
         cnt = 0;
        if(cnt&1)
        ans = max(cnt,ans);
    }
    cout<<ans;
}
Copy
Legendary moathhamudah
GNU G++17
0 ms
0 KB
Compilation Error