Beispiel #1
0
        public void CountInversions_Smoke_Test()
        {
            var arr = new int[] { 1, 20, 6, 4, 5 };

            Assert.AreEqual(5, CountInversions.Count(arr));

            arr = new int[] { 2, 4, 1, 3, 5 };
            Assert.AreEqual(3, CountInversions.Count(arr));

            arr = new int[] { 12, 11, 13, 5, 6, 7 };
            Assert.AreEqual(10, CountInversions.Count(arr));
        }
Beispiel #2
0
        public void TestCase0()
        {
            using (StreamReader sr = new StreamReader(@"HackerRank\CountInversions_TestCase0.txt"))
            {
                int t = Convert.ToInt32(sr.ReadLine());

                for (int tItr = 0; tItr < t; tItr++)
                {
                    int n = Convert.ToInt32(sr.ReadLine());

                    int[] arr = Array.ConvertAll(sr.ReadLine().Split(' '), arrTemp => Convert.ToInt32(arrTemp))
                    ;
                    long result = CountInversions.countInversions(arr);

                    Console.WriteLine(result);
                }
            }
        }