Topic — Add New » Posts Last Poster Freshness
Add two Numbers 3 spandan 2 days

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8

Amazon Banglore Online Written 3 sandeepKNJ 3 weeks

Given a single linked list with an additional pointer to a random node (which can also be NULL), clone the list and return it.

Example:

One arrow points to the next element, while the other points to the 'random' element. If there is only one arrow out of a node, it points to the next node. Clone and return the head of the new list alone.

Note: Your code will not be considered for evaluation if you just return the input list as the cloned list.

WAP to find middle of a linked list in single pass 3 rao_555 3 weeks

1. Take two pointers P1 and P2, both pointed to the first element.
2. Increment P1 by 1 and P2 by 2.
3. Whenever P2 reaches to the end, P1 will be at the middle of the list"

int getMiddle(struct node *p)
{
  int mid;
  struct node *p1,*p2;
  p1=p2=p;
  while(p2->link != NULL && p2->link->link != NULL)
  {
    p1=p1->link;
    p2=p2->link->link;
  }
  return p1->data;
}
swap node of double link list....debug help 4 Guddu Sharma 1 month

could you please help me debug this code.

this is a code to swap two node of double link list.
i am not able to figure out , where i am doing wrong :( :(

here is the code:-

dll* swap_node(dll *head,dll *node1,dll *node2)
{
dll *tmp;
int flag=0;
   if(node1->prev!=NULL)
   {
       node1->prev->next=node2;
   }
   else
   {

       flag=1;
   }
   if(node1->next!=NULL)
   {
       node1->next->prev=node2;
   }

   if(node2->prev!=NULL)
   {
  ...
circular linked list node deletion 6 Guddu Sharma 1 month

Write code to delete a given node from circular linked list.

Merge N linked lists into one of the existing 3 Guddu Sharma 1 month

Given N unsorted single linked lists of same size, merge the lists into one of the existing.

Convert circular linklist into liner list 3 Aashish Barnwal 1 month

There is one link list which has a loop. Which link need to be removed to convert it into the linear linklist.

a--->b--->c--->d--->e--->f---->g---|
                              |___________|

In this above linklist link from g to e should be removed to convert this circulat link list to linear link list.

[Linked List]Aricent Interview question 3 Aashish Barnwal 1 month

There are two linked list l1 and l2.
l2 is merged with l1.
U have to return the address of the node at which l2 has been merged to l1.

Can anybody help me to find the solution to this question??

[closed] union & intersection of unsorted lists 5 geeksforgeeks 1 month

Print the union and intersection of two linked lists in minimum time possible. The lists are not in sorted order.

Reverse linked list with arbit / random pointer using constant space 1 sparco 2 months

Consider a Linked List with each Node, in addition to having a 'next' pointer also has a 'random' pointer. The 'random' pointer points to some random other Node on the linked list. It may also point to NULL. To simplify things, no two 'random' pointers will point to the same node, but more than 1 Node's random pointer can point to NULL.

Now we are required to reverse the direction of all the pointers (both the 'next' and 'random') of the Linked list. The constraint is the solution MUST...

SUBTRACT 2 link lists 2 kartik 2 months

Subtract 2 lists.They are as shown below:

[b]CASE1:
[/b]
LIST 1:
1 --> 2 --> 3 -->4 -->NULL

LIST 2:
2 --> 3 -->4 -->NULL

ANSWER:
1 --> 0 --> 0 -->0 -->NULL

[b]CASE2:
[/b]
LIST 1:
2 --> 3 -->4 -->NULL

LIST 2:
4 --> 3 -->4 -->NULL

ANSWER:
-2 --> 0 -->0 -->NULL

Reverse a linked list every "given num" nodes 2 kartik 3 months

Input (num = 3)
1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10

Output
3 -> 2 -> 1 -> 6 -> 5 -> 4 -> 9 -> 8 -> 7 -> 10

public static LinkedListNode reverseWhole(LinkedListNode head, int num) {
	if (head == null || head.next == null)
		return head;
	LinkedListNode[] headAndTail = reversePart(head, num);
	LinkedListNode newHead = headAndTail[0];
	LinkedListNode tail = headAndTail[1];
	LinkedListNode next = tail....
Find 0 sum elements in three Linked lists 9 gvk 4 months

Given three lists: A, B and C of length n each. Write a function which returns true if any 3 three numbers (1 from each list), sum up to zero. Else return false, if there is no such combination.

Recursively reverse 2 kartik 4 months

Give an efficient algorithm to RECURSIVELY reverse a singly linked list with minimum time and space complexity

programs of data structures 2 4 months
Reversing doubly linked list 5 camster 4 months

Give an algorithm to reverse a doubly linked list in less than linear time

LINK LIST 3 camster 5 months

EFFICIENT METHOD OF REVERSE A LINK LIST USING SINGLE POINTER ONLY , NO EXTRA POINTER IS USED