Example #1
0
        public int solution2(int[] A)
        {
            A = A.Distinct().ToArray();//todo use only algorit

            int size = A.Length;

            HackerRankSearchAlgorithms.BubbleSort(ref A, size);

            if (A[size - 1] < 0)//check if ther is negative number after distinct
            {
                return(1);
            }
            for (int i = 0; i < size; i++)
            {
                if (A[i] != i + 1) //missing order
                {
                    return(i + 1); //return real count
                }
                else if (i == size - 1)
                {
                    return(i + 2);//return real count + next order
                }
            }
            return(1);
            // write your code in C# 6.0 with .NET 4.5 (Mono)
        }
        public static void BreakAppCall()
        {
            var qutLines = Convert.ToInt32(Console.ReadLine());

            string[] lines = new String[qutLines];

            for (int i = 0; i < qutLines; i++)
            {
                lines[i] = Console.ReadLine();
            }

            Console.WriteLine(HackerRankSearchAlgorithms.BreakApp(qutLines, lines));
        }