Exemplo n.º 1
0
        public void Test_1(string caseName, int numberVertices, int[] parent, int expected)
        {
            var f0   = new HeightOfTreeFromParentArray();
            var tree = f0.CalculateTreeHeight(parent);

            tree.ShouldBe(expected);
        }
Exemplo n.º 2
0
        public void Run(string[] args)
        {
            var solution = new HeightOfTreeFromParentArray();

            var numVertices = Console.ReadLine().Split(' ').Select(n => Convert.ToInt32(n)).ToArray();
            var parent      = Console.ReadLine().Split(' ').Select(n => Convert.ToInt32(n)).ToArray();

            Console.WriteLine(solution.CalculateTreeHeight(parent));
        }
Exemplo n.º 3
0
        public void Large_Input()
        {
            var expected = 100000;

            var large = new int[expected];

            large[0] = -1;
            for (int i = 0; i < expected; i++)
            {
                large[i] = i - 1;
            }

            var f0   = new HeightOfTreeFromParentArray();
            var tree = f0.CalculateTreeHeight(large);

            tree.ShouldBe(expected);
        }