Skip to content

Category Archives: C++ Programs

Write code to find lexicographic minimum in a circular array, e.g. for the array BCABDADAB, the lexicographic minimum is ABBCABDADInput Constraint: 1 < n <… Read More
Given two sorted lists, merge them so as to produce a combined sorted list (without using extra space).Examples: Input: head1: 5->7->9 head2: 4->6->8 Output: 4->5->6->7->8->9… Read More
Given a string S containing lowercase English alphabets, and a matrix shift[][] consisting of pairs of the form{direction, amount}, where the direction can be 0… Read More
Given an array of n integers, find the third largest element. All the elements in the array are distinct integers. Example :   Input: arr[] = {1,… Read More
Given an array that is sorted and then rotated around an unknown point. Find if the array has a pair with a given sum ‘x’.… Read More
Given a matrix, clockwise rotate elements in it. Examples: Input 1 2 3 4 5 6 7 8 9 Output: 4 1 2 7 5… Read More
Given a linked list where every node represents a linked list and contains two pointers of its type:  Pointer to next node in the main… Read More
Given string str, the task is to find the minimum number of characters to be inserted to convert it to a palindrome. Before we go… Read More
Given a singly linked list, Your task is to remove every K-th node of the linked list. Assume that K is always less than or… Read More
Given a singly linked list, write a function to swap elements pairwise. Input: 1->2->3->4->5->6->NULL Output: 2->1->4->3->6->5->NULL Input: 1->2->3->4->5->NULL Output: 2->1->4->3->5->NULL Input: 1->NULL Output: 1->NULL  For example, if the… Read More
QuickSort on Doubly Linked List is discussed here. QuickSort on Singly linked list was given as an exercise. The important things about implementation are, it… Read More
Write a function that searches a given key ‘x’ in a given singly linked list. The function should return true if x is present in… Read More
Write a function to count the number of nodes in a given singly linked list. For example, the function should return 5 for linked list… Read More
Write a GetNth() function that takes a linked list and an integer index and returns the data value stored in the node at that index… Read More

Start Your Coding Journey Now!