## VMWare Inc Interview Question for Software Engineer / Developers

Comment hidden because of low score. Click to expand.
0
of 0 vote

Hi can u plz send that code

Comment hidden because of low score. Click to expand.
0
of 0 vote

Comment hidden because of low score. Click to expand.
0
of 0 vote

I finaly figured out three solutions to this:
1. if you are allowed to use only one temp pointer
keep swaping elements i.e. 1 and 2 , then 2 and 3 , then 3 and 4...sna so on...till 1st elemet reaches nth position.
againuse the same funda for swap but this time swap only n-1 times.
This method is little slower.

2. Conventional way.
static void Reverse(struct node** headRef) {
struct node* result = NULL;
struct node* next;
while (current != NULL) {
next = current->next; // tricky: note the next node
current->next = result; // move the node onto the result
result = current;
current = next;
}
}
3. Use Stacks or recursive functions.
you can use recursive rutines here..same as stack as recursive functions internally uses stacks
struct node* first;
struct node* rest;
if (*headRef == NULL) return; // empty list base case
first = *headRef; // suppose first = {1, 2, 3}
rest = first->next; // rest = {2, 3}
if (rest == NULL) return; // empty rest base case
RecursiveReverse(&rest); // Recursively reverse the smaller {2, 3} case
// after: rest = {3, 2}
first->next->next = first; // put the first elem on the end of the list
first->next = NULL; // (tricky step -- make a drawing)
}

Comment hidden because of low score. Click to expand.
0
of 0 vote

void reverse()
{
struct node* temp = p;
struct node *q, *r;
q = temp->next;
temp->next = NULL;
while(q != NULL)
{
r = q->next;
q->next = temp;
temp = q;
q = r;
}
p = temp;
}

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.