# It is giving Output limit Exceeded here. It works fine in my system.

• This following program which I have written for anagrams question is working fine in my system , but it is giving an error "output limit exceeded" in here. Can anyone please tell me if there is any mistake.

``````class Solution {
map<char,int> arrayOfNumbers;

public:

bool prime1(int num){
if(num %2 == 0)return false;
for(int i=3;i*i<=num;i+=2){
if(num%i ==0 )return false;
}
return true;
}

void arrayChar(){
int prime=2;
char first='a';
for(int i=2;(int)first <= (int)'z';i++){
if(prime1(i)){
arrayOfNumbers[first]=i;
first=first+1;
}
}
}

int hashNumber(string str){
int Number=1;
for(int i=0;i<str.length();i++){
Number=Number*arrayOfNumbers[str[i]];
}
return Number;
}
vector<string> anagrams(vector<string> &strs) {
arrayChar();
map<int, vector<string> > listOfAnagrams;
int HashNumber;
for(int i=0;i<strs.size();i++){
HashNumber=hashNumber(strs[i]);
listOfAnagrams[HashNumber].push_back(strs[i]);
}
vector<string> Result;
Result.reserve(strs.size());
for (std::map<int, vector<string> >::iterator it=listOfAnagrams.begin(); it!=listOfAnagrams.end(); ++it)
{
Result.insert(Result.end(),it->second.begin(),it->second.end());
}
return Result;
}
};``````

• your " hash number " will make "de" equal to "cf". am i right?

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.