• + 1 comment

    c# solution :

    public static SinglyLinkedListNode deleteNode(SinglyLinkedListNode llist, int position)
        {
            int i = 0;
            var temp = llist;
           
            while (temp != null)
            {
                if (i == position)
                {
                    return null;
                }
                if (i == position -1 )
                {
                    if (temp.next.next != null)
                    {
                        temp.next.data = temp.next.next.data;
                        temp.next.next = temp.next.next.next;
                    }
                    else
                    {
                        temp.next = null;
                    }
    
                    return llist;
                }
                temp = temp.next;
                i++;
            }
            return llist;
        }