Translate

Views

Monday, July 29, 2019

Solution Kattis: No Duplicates

https://open.kattis.com/problems/nodup
#include<bits/stdc++.h>
using namespace std;

map<string, int> m;
string s;

bool check(){
 for(map<string, int> :: iterator it=m.begin(); it!=m.end(); it++) 
  if (it->second > 1) return false;
 return true;
}

int main(){
 while(cin >> s) m[s]++;
 if (check()) cout<<"yes"; else cout<<"no";
}
Good luck! If you need help please leave a comment :) 

No comments: