public void DeleteDups_UsingTwoPointer(MyLinkedListNode head)
        {
            Console.WriteLine($"{this.GetType().FullName}.{System.Reflection.MethodBase.GetCurrentMethod().Name}\n");
            head.PrintForward("List-Before:");

            int tapB = 0;

            if (head == null)
            {
                return;
            }

            var current = head;

            while (current != null)
            {
                /* Remove all future nodes that have the same value */
                var runner = current;

                while (runner.Next != null)
                {
                    tapB++;
                    Console.WriteLine($"current.Data '{current.Data}' runner.Next.Data: '{runner.Next.Data}'");

                    if (runner.Next.Data.Equals(current.Data))
                    {
                        Console.WriteLine($"Removing runner '{runner.Next.Data}'");
                        runner.Next = runner.Next.Next;
                        head.PrintForward();
                    }
                    else
                    {
                        runner = runner.Next;
                    }
                }
                current = current.Next;
            }
            head.PrintForward("List-After\n");
            Console.WriteLine("-------------------------------------------------------");
        }
        public MyLinkedListNode ReverseLinkedListRecursiveInt(MyLinkedListNode head, MyLinkedListNode newHead)
        {
            if (head == null)
            {
                return(newHead);
            }
            head.PrintForward("*head");
            //if (newHead != null)
            //    newHead.PrintForward("*newHead");
            MyLinkedListNode nextNode = head.Next;

            head.Next = newHead;
            return(ReverseLinkedListRecursiveInt(nextNode, head));
        }
        public void MeargeList_Run()
        {
            int[]            firstVals = { 1, 3, 6, 8 };
            MyLinkedListNode firstList = CreateLinkedListFromArray(firstVals);

            firstList.PrintForward("firstList");
            int[]            SecondVals = { 0, 2, 4, 5, 7, 9, 10 };
            MyLinkedListNode secondList = CreateLinkedListFromArray(SecondVals);

            secondList.PrintForward("secondList");
            var meargedList = MergeTwoLists_Int(firstList, secondList);

            meargedList.PrintForward("meargedList");
        }
            public Result NthToLast_3_Recurssive_ExternalCounterAndNode_Helper(MyLinkedListNode head, int k)
            {
                if (head == null)
                {
                    return(new Result(null, 0));
                }
                head.PrintForward($"*** k='{k}'  result.Node='{head.NodeValue()}'");
                var result = NthToLast_3_Recurssive_ExternalCounterAndNode_Helper(head.Next, k);

                head.PrintForward($"*** k='{k}' result.Count='{result.Count}' result.Node='{result.Node.NodeValue()}'");

                if (result.Node == null)
                {
                    result.Count++;

                    if (result.Count == k)
                    {
                        Console.WriteLine($"{k}th element is '{head.Data}'");
                        result.Node = head;
                    }
                }

                return(result);
            }
            public void Run()
            {
                /* Create linked list */
                int[]            vals  = { -1, -2, 0, 1, 2, 3, 4, 5, 6, 7, 8 };
                MyLinkedListNode list1 = CreateLinkedListFromArray(vals);

                list1.PrintForward("list1");
                int[]            vals2 = { 12, 14, 15 };
                MyLinkedListNode list2 = CreateLinkedListFromArray(vals2);

                list2.PrintForward("list2");
                //adding some common elements
                list2.Next.Next = list1.Next.Next.Next.Next;
                list2.PrintForward("list2");
                MyLinkedListNode intersection = findIntersection(list1, list2);

                intersection.PrintForward("intersection");
            }
        public void DeleteDupsC_InProgress(MyLinkedListNode head)
        {
            int tabC = 0;

            head.PrintForward("List-Before\n");
            Console.WriteLine($"{this.GetType().FullName}.{System.Reflection.MethodBase.GetCurrentMethod().Name}\n");

            if (head == null)
            {
                return;
            }

            var previous = head;
            //Next element
            var current = previous.Next;

            while (current != null)
            {
                // Look backwards for dups, and remove any that you see.
                var runner = head;

                head.PrintForward();
                current.PrintForward();
                runner.PrintForward();

                while (runner != current && current != null)
                {
                    runner.PrintForward();

                    tabC++;
                    Console.WriteLine($"@@current.Data '{current.Data}' runner.Data: '{runner.Data}'");
                    if (runner.Data.Equals(current.Data))
                    {
                        head.PrintForward();
                        current.PrintForward();
                        previous.PrintForward();
                        //Console.WriteLine($"@@Removing current '{current.Data}'");
                        //urrent = current.Next;

                        var temp = current.Next;
                        previous.Next = temp;
                        current       = temp;
                        //Console.WriteLine($"***Inner current {current.PrintForward()}");
                        //previous = current;
                        //current = temp;

                        /* We know we can't have more than one dup preceding
                         * our element since it would have been removed
                         * earlier. */
                        //break;
                        //Console.WriteLine($"{head.PrintForward()}");
                    }

                    runner = runner.Next;
                    runner.PrintForward();
                }

                /* If runner == current, then we didn�t find any duplicate
                 * elements in the previous for loop.  We then need to
                 * increment current.
                 * If runner != current, then we must have hit the �break�
                 * condition, in which case we found a dup and current has
                 * already been incremented.*/
                if (runner == current)
                {
                    head.PrintForward();
                    previous.PrintForward();
                    current.PrintForward();
                    runner.PrintForward();
                    previous = current;
                    current  = current.Next;
                    previous.PrintForward();
                    //Console.WriteLine($"@@@current {current.PrintForward()}");
                }
            }
            head.PrintForward("List-After\n");
            Console.WriteLine("-------------------------------------------------------");
        }