Esempio n. 1
0
        static void Main(string[] args)
        {
            do
            {
                Console.WriteLine("Select \n1. Sum close to zero in an array\n2. Get row with maximum number of 1 \n3. Reverse linked list \n4. Length of longest valid substring ");
                int opt = Convert.ToInt32(Console.ReadLine());
                switch (opt)
                {
                case 1:
                    SumCloseToZero.GetSumCloseToZero();
                    break;

                case 2:
                    RowWithMaximunOne.GetRowWithMaxOne();
                    break;

                case 3:
                    ReverseList.ReverseLinkList();
                    break;

                case 4:
                    LongestSubstring.GetLongestSubstring();
                    break;

                default:
                    Console.WriteLine("Wrong Input.");
                    break;
                }
                Console.WriteLine("\n\nDo you want to continue?(Y/N)");
            }while (Console.ReadLine().ToUpper() == "Y");
        }
Esempio n. 2
0
        public static void GetRowWithMaxOne()
        {
            RowWithMaximunOne obj = new RowWithMaximunOne();

            int[][] rows = new int[4][];
            rows[0] = new int[] { 0, 1, 1, 0, 1 };
            rows[1] = new int[] { 1, 1, 1, 1, 0 };
            rows[2] = new int[] { 0, 0, 1, 0, 0 };
            rows[3] = new int[] { 1, 1, 1, 1, 1 };
            Console.WriteLine("\nInput : ");
            for (int i = 0; i < rows.Length; i++)
            {
                for (int j = 0; j < rows[i].Length; j++)
                {
                    Console.Write((j == 0 ? "\n" : " ") + rows[i][j]);
                }
            }
            obj.GetRow(rows);
        }