Empresa activa
Reverse a linked list
Anónimo
reverse without recursion: Node*reverse(Node *root){ Node* prev=NULL,*current=root; while(current){ tmp = current->next; current->next = prev; prev = current; current = tmp; } }
Node * reverse( Node * ptr , Node * previous) { Node * temp; if(ptr->next == NULL) { ptr->next = previous; return ptr; } else { temp = reverse(ptr->next, ptr); ptr->next = previous; return temp; } }
Maintain two/three pointer , pointer to the remaning list while one is being reversed, and then loop till the end
Sigue a tus empresas favoritas para estar al tanto de las últimas oportunidades y disponer de información de primera mano.
Recibe recomendaciones y actualizaciones personalizadas al iniciar tu búsqueda.