Given a file, find the ten most frequently occurring words as efficiently as possible

后端 未结 15 1698
予麋鹿
予麋鹿 2020-12-12 13:26

This is apparently an interview question (found it in a collection of interview questions), but even if it\'s not it\'s pretty cool.

We are told to do this efficien

15条回答
  •  情深已故
    2020-12-12 14:08

        int k = 0;
        int n = i;
        int j;
        string[] stringList = h.Split(" ".ToCharArray(),
                                      StringSplitOptions.RemoveEmptyEntries);
        int m = stringList.Count();
        for (j = 0; j < m; j++)
        {
            int c = 0;
            for (k = 0; k < m; k++)
            {
                if (string.Compare(stringList[j], stringList[k]) == 0)
                {
                    c = c + 1;
                }
            }
        }
    

提交回复
热议问题