Beispiel #1
0
        public static void isPalindrome()
        {
            var number1 = new myLinkedList <int>
            {
                data = 1,
                Next = new myLinkedList <int>
                {
                    data = 2,
                    Next = new myLinkedList <int>
                    {
                        data = 3,
                        Next = new myLinkedList <int>
                        {
                            data = 2,
                            Next = new myLinkedList <int>
                            {
                                data = 1,
                            }
                        }
                    }
                }
            };
            var obj = new CareerCupQnA();

            Console.WriteLine(
                obj.CheckPalindromeInLinkedList(number1, new Dictionary <int, int>(), 0, 5));
        }
Beispiel #2
0
        public static void RemoveDuplicatesinLinkedList()
        {
            var number1 = new myLinkedList <int>
            {
                data = 2,
                Next = new myLinkedList <int>
                {
                    data = 5,
                    Next = new myLinkedList <int>
                    {
                        data = 6,
                        Next = new myLinkedList <int>
                        {
                            data = 5,
                            Next = new myLinkedList <int>
                            {
                                data = 9,
                                Next = new myLinkedList <int>
                                {
                                    data = 1
                                }
                            }
                        }
                    }
                }
            };

            var obj = new CareerCupQnA();

            obj.RemoveDuplicatesInLinkedList(number1);
        }
Beispiel #3
0
        public static void MultiplyLinkedLists()
        {
            var obj = new CareerCupQnA();

            var number1 = new myLinkedList <int>
            {
                data = 2,
                Next = new myLinkedList <int>
                {
                    data = 5,
                    Next = new myLinkedList <int>
                    {
                        data = 6
                    }
                }
            };

            var number2 = new myLinkedList <int>
            {
                data = 1,
                Next = new myLinkedList <int>
                {
                    data = 3
                }
            };

            obj.Multiply2LinkedList(number1, number2);
        }
Beispiel #4
0
        private static void SwapPairsInLinkedList()
        {
            var linkedList = new myLinkedList <int>();
            var number1    = new myLinkedList <int>
            {
                data = 1,
                Next = new myLinkedList <int>
                {
                    data = 2,
                    Next = new myLinkedList <int>
                    {
                        data = 3,
                        Next = new myLinkedList <int>
                        {
                            data = 4,
                            Next = new myLinkedList <int>
                            {
                                data = 5
                            }
                        }
                    }
                }
            };

            var number2 = new myLinkedList <int>
            {
                data = 1,
            };

            var output = new CareerCupQnA().SwapPairs(number2);
        }
Beispiel #5
0
        static void MergeSortedArray()
        {
            var number1 = new myLinkedList <int>
            {
                data = 2,
                Next = new myLinkedList <int>
                {
                    data = 5,
                    Next = new myLinkedList <int>
                    {
                        data = 6
                    }
                }
            };

            var number2 = new myLinkedList <int>
            {
                data = 1,
                Next = new myLinkedList <int>
                {
                    data = 3,
                    Next = new myLinkedList <int>
                    {
                        data = 99,
                        Next = new myLinkedList <int>
                        {
                            data = 100,
                            Next = new myLinkedList <int>
                            {
                                data = 1009,
                                Next = new myLinkedList <int>
                                {
                                    data = 1051,
                                }
                            }
                        }
                    }
                }
            };

            var obj = new CareerCupQnA();
            var res = obj.MergeSortedArray(number1, number2);

            while (res != null)
            {
                Console.WriteLine(res.data);
                res = res.Next;
            }
        }
Beispiel #6
0
        public static void FindtheNthElement()
        {
            var obj     = new CareerCupQnA();
            var number1 = new myLinkedList <int>
            {
                data = 2,
                Next = new myLinkedList <int>
                {
                    data = 5,
                    Next = new myLinkedList <int>
                    {
                        data = 6
                    }
                }
            };
            var a = obj.FindnthElement(number1, 10);

            Console.WriteLine(a.data);
        }
Beispiel #7
0
        static void ReverseLinkedList1()
        {
            var obj     = new CareerCupQnA();
            var number1 = new myLinkedList <int>
            {
                data = 2,
                Next = new myLinkedList <int>
                {
                    data = 5,
                    Next = new myLinkedList <int>
                    {
                        data = 6
                    }
                }
            };
            var res = obj.ReverseALinkedList(number1);

            while (res != null)
            {
                Console.WriteLine(res.data);
                res = res.Next;
            }
        }