コード例 #1
0
        public static LLNode GetNode(LLNode node, int position)
        {
            if (node == null || position == 0)
            {
                return(node);
            }

            Stack <LLNode> stack   = new Stack <LLNode>();
            int            counter = 0;
            LLNode         result  = null;

            while (node != null)
            {
                stack.Push(node);
                node = node.next;
            }

            while (counter < position)
            {
                result = stack.Pop();
            }

            return(result);
        }