Professional Documents
Culture Documents
2. 6
You are given a list of n-1 integers and these integers are in
the range of 1 to n. There are no duplicates in list. One of the
integers is missing in the list. Write an efficient code to find
the missing integer
3. 7 Given a singly linked list, write a function to swap elements
pairwise. For example, if the linked list is 1->2->3->4->5->6-
>7 then the function should change it to 2->1->4->3->6->5->7,
and if the linked list is 1->2->3->4->5->6 then the function
should change it to 2->1->4->3->6->5
4. Amazo Given a link list with right pointers and each element of the
n list has a down link contains another link list with down
pointers as:
9
5 -> 7 -> 9 -> 18
| | | |
10 6 14 20
| | | |
11 8 19 22
| | |
Page 1 of 12
FINDMIND Boot-Camp June 2014
12 13 24
|
15
5. 8
Given a linked list containing character in each node,
segregate its nodes in such a way that all nodes containing a
vowel are moved to the end of the linked list. We will have to
maintain the order.
6. 8
You are given two linked lists whose nodes contain a digit as
data member. Both lists represent a number. You have to add
them and return the resultant list.
Input: 9->9->3->4->5 and 8->9->1 (represent 99345 and 891)
Output: 1->0->0->2->3->6
7. 6
Delete nth node from end of a linked list in a single scan.
8. 7
Given a linked list, sort without extra space.
9. 7 A singly link list and a number ‘K’, swap the Kth node from
the start with the Kth node from the last. Check all the edge
cases.
Sample Input: 1->2->3->4->5->6->7->8 and K = 3
Sample Output : 1->2->6->4->5->3->7->8
Page 2 of 12
FINDMIND Boot-Camp June 2014
11. 8
Given a circular linked list, you have to split the linked list
into two another circular linked list. If it contains 2n+1 nodes,
then first list should contain n+1 nodes and second list should
contain n nodes.
12. 8 Given linked list as a-x-b-y-c-z
output it as a-b-c-z-y-x
that is reverse alternate element and append to end of list
You are given a Double Link List with one pointer of each
node pointing to the next node just like in a single link list.
The second pointer however CAN point to any node in the list
and not just the previous node. Now write a program in O(n)
time to duplicate this list. That is, write a program which will
create a copy of this list.
Page 3 of 12
FINDMIND Boot-Camp June 2014
Figure 1
Page 4 of 12
FINDMIND Boot-Camp June 2014
Figure 2
copy_list_node->arbit =
copy_list_node->arbit->arbit->next;
copy_list_node = copy_list_node->next;
Page 5 of 12
FINDMIND Boot-Camp June 2014
original->next->arbitrary = original->arbitrary->next;
/*TRAVERSE
TWO NODES*/
original->next = original->next->next;
copy->next = copy->next->next;
Page 6 of 12
FINDMIND Boot-Camp June 2014
16. 8 Given a singly linked list, rotate the linked list counter-
clockwise by k nodes. Where k is a given positive integer. For
example, if the given linked list is 10->20->30->40->50->60 and
k is 4, the list should be modified to 50->60->10->20->30->40.
Assume that k is smaller than the count of nodes in linked
list.
17. 8 Given a linked list where every node represents a linked list
and contains two pointers of its type:
(i) Pointer to next node in the main list (we call it ‘right’
pointer in below code)
(ii) Pointer to a linked list where this node is head (we call it
‘down’ pointer in below code).
All linked lists are sorted. See the following example
8 50 40
| |
V V
30 45
Page 8 of 12
FINDMIND Boot-Camp June 2014
20. 8
Write a code for implementation of doubly linked list with use
of single pointer in each node.
21. 7 Implement Stack using Queues
Page 9 of 12
FINDMIND Boot-Camp June 2014
23. 7 Given two linked lists, we need to find out that if two linked
list merge, if yes, find merge point.
For example:
24. 7 Given a singly linked list, which may or may not contain a
loop in it, we need to find out whether there is a loop and it
yes, start of the loop should be returned.
Page 10 of 12
FINDMIND Boot-Camp June 2014
For example,
Input lists
Result should be
Resultant list
26. 10
Given 2 sorted linked list , merge them into single sorted list.
Change the pointers, don't copy data
27. 10
Write code to find the next least node in a binary search tree
given a node?
28. 10
Write a routine to reverse every k nodes in a given linked list
without using additonal memory.
30. 10
Append the last n nodes of a linked list to the beginning of the
list
eg: 1->2->3->4->5->6
if n=2
5->6->1->2->3->4
31. 10
Given two linked lists combine them in a way such that the
resultant must contain the elements alternatively from one
list and the other list?
For ex.
LL1 : 1->2->3->4
LL2 : 5->6->7
Result : 1->5->2->6->3->7->4
Page 12 of 12