Advertisement
Zeinab_Hamdy

Untitled

Nov 25th, 2022
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. int pickCoupons(int n, vector<int> &v)
  3. {
  4.    set < int > st (v.begin() , v.end());
  5.     if(st.size()==n) return -1;
  6.     int ans=INT_MAX;
  7.     for(int i=0;i<n;i++){
  8.         for(int j= i+1 ; j < n ;j++){
  9.             if(v[j]==v[i]){
  10.                 ans= min(ans , j-i+1);
  11.                 break;
  12.             }
  13.         }
  14.     }
  15.     return ans ;
  16. }
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement