示例#1
0
        public void TestMethod1(int[] nums, int k, int[] expected)
        {
            // Arrange
            TopKFrequentElements question = new TopKFrequentElements();

            // Act
            IList <int> actual = question.TopKFrequent(nums, k);

            // Assert
            CollectionAssert.AreEqual(new List <int>(expected), new List <int>(actual));
        }
        public void TopKFrequentTest2()
        {
            int[] nums = { 1, 2 };
            int   k    = 2;

            int[] expected = { 1, 2 };
            for (int i = 0; i < expected.Length; i++)
            {
                var result = new TopKFrequentElements().TopKFrequent(nums, k);
                if (!result.Contains(expected[i]))
                {
                    Assert.Fail();
                }
            }

            Assert.Pass();
        }
示例#3
0
 public void Setup()
 {
     solution = new TopKFrequentElements();
 }
示例#4
0
        static void Main(string[] args)
        {
            var solution = new TopKFrequentElements();

            Console.WriteLine(string.Join(",", solution.Solve(new int[] { 1, 1, 1, 2, 2, 3 }, 2)));
        }
 public void BeforeEach()
 {
     TopKFrequentElements = new TopKFrequentElements();
 }