<commit_before>// Source : https://oj.leetcode.com/problems/anagrams/
// Author : <NAME>
// Date   : 2014-07-18

/********************************************************************************** 
* 
* Given an array of strings, return all groups of strings that are anagrams.
* 
* Note: All inputs will be in lower-case.
*               
**********************************************************************************/

class Solution {
public:
    vector<string> anagrams(vector<string> &strs) {
        vector<string> result;
        map<string, string> m;
        for(int i=0; i<strs.size(); i++){
            string word = strs[i];
            sort(word.begin(), word.end());
            if (m.find(word)==m.end()){
                m[word] = strs[i];
            }else{
                if (m[word]!="#"){
                    result.push_back(m[word]);
                    m[word]="#";
                }
                result.push_back(strs[i]);
            }
        }
        return result;
    }
};<commit_msg>[Anagrams] Reduce memory cost<commit_after>// Source : https://oj.leetcode.com/problems/anagrams/
// Author : <NAME>
// Date   : 2014-07-18

/********************************************************************************** 
* 
* Given an array of strings, return all groups of strings that are anagrams.
* 
* Note: All inputs will be in lower-case.
*               
**********************************************************************************/

class Solution {
public:
    vector<string> anagrams(vector<string> &strs) {
        vector<string> result;
        map<string, int> m;
        for(int i=0; i<strs.size(); i++){
            string word = strs[i];
            sort(word.begin(), word.end());  // Why not use a better hashing technique?
            if (m.find(word)==m.end()){
                m[word] = i;
            }else{
                if (m[word]>=0){
                    result.push_back(strs[m[word]]);
                    m[word]=-1;
                }
                result.push_back(strs[i]);
            }
        }
        return result;
    }
};
{'fraction_non_alphanumeric': 0.2840800762631077, 'fraction_numerical': 0.009532888465204958, 'mean_word_length': 2.0158045977011496, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 14, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3069443', 'n_tokens_mistral': 619, 'n_tokens_neox': 578, 'n_words': 128}