public void TestMethod2()
        {
            var input  = new string[] { "the", "day", "is", "sunny", "the", "the", "the", "sunny", "is", "is" };
            var result = new TopKFrequentWords().TopKFrequent(input, 4);
            var output = new string[] { "the", "is", "sunny", "day" };

            CollectionAssert.AreEqual(output.ToList(), result.ToList());
        }
        public void TestMethod1()
        {
            var input  = new string[] { "i", "love", "leetcode", "i", "love", "coding" };
            var result = new TopKFrequentWords().TopKFrequent(input, 2);
            var output = new string[] { "i", "love" };

            CollectionAssert.AreEqual(output.ToList(), result.ToList());
        }
Example #3
0
        public void TestCase1()
        {
            //arrange
            var input = new string[] { "i", "love", "leetcode", "i", "love", "coding" };
            var k     = 2;

            //act
            var result = TopKFrequentWords.FrequentWords(input, k);

            //assert
            Assert.That(result[0], Is.EqualTo("i"));
        }
        public void Top2MostFrequentWords()
        {
            // arrange
            // Input: ["i", "love", "leetcode", "i", "love", "coding"], k = 2
            string[]      words    = new [] { "i", "love", "leetcode", "i", "love", "coding" };
            int           k        = 2;
            List <string> expected = new List <string> {
                "i", "love"
            };

            // act
            List <string> mostFreqWords = new List <string>(TopKFrequentWords.TopKFrequent(words, k));

            // assert
            CollectionAssert.AreEqual(expected, mostFreqWords);
        }
        public void Top4MostFrequentWords()
        {
            // arrange
            string[] words = new[] { "the", "day", "is", "sunny", "the", "the", "the", "sunny", "is", "is" };
            int      k     = 4;

            List <string> expectedWords = new List <string> {
                "the", "is", "sunny", "day"
            };

            // act
            IList <string> result           = TopKFrequentWords.TopKFrequent(words, k);
            List <string>  mostFequentWords = new List <string>(result);

            // assert
            CollectionAssert.AreEqual(expectedWords, mostFequentWords);
        }