Example #1
0
        public static void Execute()
        {
            // read the string s.
            string s = Console.ReadLine();

            // create the Solution class object p.
            QueuesStacks obj = new QueuesStacks();

            // push/enqueue all the characters of string s to stack.
            foreach (char c in s)
            {
                obj.pushCharacter(c);
                obj.enqueueCharacter(c);
            }

            bool isPalindrome = true;

            // pop the top character from stack.
            // dequeue the first character from queue.
            // compare both the characters.
            for (int i = 0; i < s.Length / 2; i++)
            {
                if (obj.popCharacter() != obj.dequeueCharacter())
                {
                    isPalindrome = false;

                    break;
                }
            }

            // finally print whether string s is palindrome or not.
            if (isPalindrome)
            {
                Console.Write("The word, {0}, is a palindrome.", s);
            }
            else
            {
                Console.Write("The word, {0}, is not a palindrome.", s);
            }
        }
Example #2
0
        static void Menu()
        {
            string day;

            Console.WriteLine("Type the number of challenge that you desire to execute:");
            Console.WriteLine("0 - SimpleArraySum;");
            Console.WriteLine("1 - DataTypes;");
            Console.WriteLine("2 - Operators;");
            Console.WriteLine("3 - Conditional;");
            Console.WriteLine("4 - ClassVsInstance;");
            Console.WriteLine("5 - Loops;");
            Console.WriteLine("6 - Review;");
            Console.WriteLine("7 - Arrays;");
            Console.WriteLine("8 - DictonariesMaps;");
            Console.WriteLine("9 - Recursion;");
            Console.WriteLine("10 - Binary Numbers;");
            Console.WriteLine("11 - 2D Arrays;");
            Console.WriteLine("12 - Inheritance;");
            Console.WriteLine("13 - Abstract;");
            Console.WriteLine("14 - Scope;");
            Console.WriteLine("15 - Linked List;");
            Console.WriteLine("16 - Exception - String to Integer;");
            Console.WriteLine("17 - More Exceptions;");
            Console.WriteLine("18 - Queues and Stacks;");
            Console.WriteLine("19 - Interfaces;");
            Console.WriteLine("20 - Sorting;");
            Console.WriteLine("21 - Generics;");
            Console.WriteLine("22 - Binary Search Trees;");
            Console.WriteLine("23 - BST-Level Order Traversal;");
            day = Console.ReadLine();

            switch (day)
            {
            case "0":
                Console.WriteLine("0 - SimpleArraySum - Executing...");
                SimpleArraySum.Execute();
                break;

            case "1":
                Console.WriteLine("1 - DataTypes - Executing...");
                DataTypes.Execute();
                break;

            case "2":
                Console.WriteLine("2 - Operators - Executing...");
                Operators.Execute();
                break;

            case "3":
                Console.WriteLine("3 - Conditional - Executing...");
                Conditional.Execute();
                break;

            case "4":
                Console.WriteLine("4 - ClassVsInstance - Executing...");
                ClassVsInstance.Execute();
                break;

            case "5":
                Console.WriteLine("5 - Loops - Executing...");
                Loops.Execute();
                break;

            case "6":
                Console.WriteLine("6 - Review - Executing...");
                Review.Execute();
                break;

            case "7":
                Console.WriteLine("7 - Arrays - Executing...");
                Arrays.Execute();
                break;

            case "8":
                Console.WriteLine("8 - DictonariesMaps - Executing...");
                DictionariesMaps.Execute();
                break;

            case "9":
                Console.WriteLine("9 - Rercursion - Executing...");
                Recursion.Execute();
                break;

            case "10":
                Console.WriteLine("10 - Binary Numbers - Executing...");
                BinaryNumbers.Execute();
                break;

            case "11":
                Console.WriteLine("11 - 2D Arrays - Executing...");
                _2DArrays.Execute();
                break;

            case "12":
                Console.WriteLine("12 - Inheritance - Executing...");
                Inheritance.Execute();
                break;

            case "13":
                Console.WriteLine("13 - Abstract - Executing...");
                Abstract.Execute();
                break;

            case "14":
                Console.WriteLine("14 - Scope - Executing...");
                Scope.Execute();
                break;

            case "15":
                Console.WriteLine("15 - Linked List - Executing...");
                LinkedList.Execute();
                break;

            case "16":
                Console.WriteLine("16 - Exception - String to Integer - Executing...");
                ExceptionStringToInt.Execute();
                break;

            case "17":
                Console.WriteLine("17 - More Exceptions - Executing...");
                MoreExceptions.Execute();
                break;

            case "18":
                Console.WriteLine("18 - Queues and Stacks - Executing... ");
                QueuesStacks.Execute();
                break;

            case "19":
                Console.WriteLine("19 - Interfaces - Executing... ");
                Interfaces.Execute();
                break;

            case "20":
                Console.WriteLine("20 - Sorting - Executing... ");
                Sorting.Execute();
                break;

            case "21":
                Console.WriteLine("21 - Generics - Executing... ");
                Generics.Execute();
                break;

            case "22":
                Console.WriteLine("22 - Binary Search Trees - Executing... ");
                BinarySearchTrees.Execute();
                break;

            case "23":
                Console.WriteLine("23 - BST-Level Order Traversal - Executing... ");
                BSTLevelOrderTraversal.Execute();
                break;

            default:
                Menu();

                break;
            }
        }