You are viewing a single comment's thread. Return to all comments →
C++ (more at https://github.com/IhorVodko/Hackerrank_solutions/tree/master , feel free to give a star :) )
SinglyLinkedListNode * deleteNode( SinglyLinkedListNode * _list , int _position ){ assert(_position >= 0); if(!_list){ return nullptr; } auto node = _list; if(_position == 0){ if(_list->next){ node = _list->next; free(_list); return node; }else{ free(_list); return nullptr; } } while(--_position && node->next){ node = node->next; } auto nodeToDelete = node->next; node->next = nodeToDelete->next; free(nodeToDelete); return _list; }
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 →
C++ (more at https://github.com/IhorVodko/Hackerrank_solutions/tree/master , feel free to give a star :) )