Close

Finding two numbers occuring once

Given an array containing all elements twice except two numbers. Write a program to find those two numbers. For example let us consider the following array {2, 3, 2, 1, 4, 1, 4, 5} The answer is {3,5} because they appear only once and all remaining elements appear twice. This question is somewhat similar to earlier…

Pair swapping in a linked list

Given a singly linked list, we have to swap the adjacent nodes in it. For example some input/output samples are given below Input                              output ————————————————- 1->2->3->4->X                      2->1->4->3->X 1->2->3->4->5->X      …