is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
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.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
#include <stdio.h>
- munai September 28, 2013#include <stdlib.h>
struct node
{
int val;
struct node *next;
};
typedef struct node node;
node *push(node *head,int value)
{
node *temp=(node *)malloc(sizeof(node));
temp->val=value;
temp->next=head;
return temp;
}
void print(node *head)
{
while(head)
{
printf("%d ",head->val);
head=head->next;
}
printf("\n");
}
node *find_middle(node *head)
{
node *fast_ptr=head, *slow_ptr=head;
while(fast_ptr && fast_ptr->next)
{
fast_ptr=fast_ptr->next->next;
slow_ptr=slow_ptr->next;
}
return slow_ptr;
}
node *merge(node *a, node *b)
{
node *result;
if(!a && !b)
return NULL;
if(!b)
return a;
if(!a)
return b;
if(a->val<=b->val)
{
result=a;
result->next=merge(a->next,b);
}
else
{
result=b;
result->next=merge(a,b->next);
}
return result;
}
int main()
{
node *start=NULL,*start2,*result;
int value;
char c;
node *middle_node;
printf("Enter value for list\n");
do
{
scanf("%d",&value);
start=push(start,value);
printf("Do you want to continue ? (y/n)");
getchar();
c=getchar();
}while(c=='y' || c=='Y');
print(start);
middle_node=find_middle(start);
start2=middle_node->next;
middle_node->next=NULL;
result=merge(start,start2);
print(result);
return 0;
}