示例#1
0
        public static void S2_6_IsPalindrome_Test()
        {
            var input = new int[] { 1, 2, 3, 4, 5, };
            var node  = LinkedNode2.CreateFromList(input);

            node.PrintNodes();

            var reversed = LinkedNode2.Reverse(node);

            reversed.PrintNodes();
        }
示例#2
0
        public static bool S2_6_IsPalindrome(LinkedNode2 l)
        {
            var         currR = LinkedNode2.Reverse(l);
            LinkedNode2 currL = l;

            while (currR != null && currL != null)
            {
                if (currR.Data != currL.Data)
                {
                    return(false);
                }
                currR = currR.Next;
                currL = currL.Next;
            }
            return(true);
        }