How does this code find duplicate characters in a string?
问题 Example: Given a string (in this example char *word ) you want to find duplicate characters (bytes). I wanted to know if someone can explain to me how the following works: int table[256] = {0}; for (int i = 0; i < len; i++) table[word[i]]++; After that you can check with another loop if duplicate or not like: for (int i = 0; i < len; i++) if (table[word[i]] > 1) { … } How does this work? I don't understand why duplicated chars are > 1 in the table? 回答1: Transferring my comments into a semi