Translate

Views

Friday, July 8, 2022

Solution Kattis - Awkward Party




Submission 9119079

IDDATEPROBLEMSTATUSCPULANGTEST CASES
911907914:01:25Awkward Party
Accepted
0.05 sC++
6/6

Files submitted

awkwardparty.cpp

#include<bits/stdc++.h>
using namespace std;
map<int, int> pos;
int main(){
int n; cin >> n;
int res= n;
for(int i=1; i<=n; i++){
int x; cin >> x;
if (pos.count(x)) res= min(res, i - pos[x]);
else
pos[x]= i;
}
cout<<res;
}

No comments: