You are viewing a single comment's thread. Return to all comments →
It is simple but I think based on the input you can assume that using position would be enough to handle going past the list. Or something like this.
Node Delete(Node head, int position) { if(position ==0){ return head.next; }else if(head == null){ return head; } Node current = head; int i = 0; while(i++ < (position-1)){ current = current.next; } current.next = current.next.next; return head; }
Seems like cookies are disabled on this browser, please enable them to open this website
Delete a Node
You are viewing a single comment's thread. Return to all comments →
It is simple but I think based on the input you can assume that using position would be enough to handle going past the list. Or something like this.