sam
BAN USER
Comments (3)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
void LinkedList::Prepend(int n)
{
Node* fast = new Node;
fast = this->list;
Node* slow = new Node;
slow = this->list;
int delta = n;
while(delta >0)
{
fast = fast->next;
delta = delta-1;
}
delta = n-delta;
while(fast->next != NULL)
{
slow = slow->next;
fast = fast->next;
}
//slow points the target node now, point it to the start
fast->next = this->list;
this->list = slow->next;
slow->next = NULL;
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
- sam September 22, 2013