Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- int pickCoupons(int n, vector<int> &v)
- {
- set < int > st (v.begin() , v.end());
- if(st.size()==n) return -1;
- int ans=INT_MAX;
- for(int i=0;i<n;i++){
- for(int j= i+1 ; j < n ;j++){
- if(v[j]==v[i]){
- ans= min(ans , j-i+1);
- break;
- }
- }
- }
- return ans ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement