最近、次のような質問を見つけました。
"Given an array of strings, return the number of distinct strings in that array."
私はこの解決策を思いついた:
1. Get number_of_strings, which equals the number of strings in the input array
2. Get number_of_non_redundant, which equals the length of the input array cast as a set
3. Return 2 times number_of_non_redundant - number_of_strings
だから、私の質問は、このアルゴリズムはすべてのデータセットで機能しますか?