Skip to content

Category Archives: C++ Programs

Given a linked list, write a function to reverse every k nodes (where k is an input to the function).  Example:  Input: 1->2->3->4->5->6->7->8->NULL, K =… Read More
Given an array arr[] of size n and integer k such that k using namespace std;    // Prints beginning and ending indexes of subarray… Read More
Write code to find lexicographic minimum in a circular array, e.g. for the array BCABDADAB, the lexicographic minimum is ABBCABDAD.Source: Google Written TestMore Examples:  Input:… Read More
Write a function rotate(ar[], d, n) that rotates arr[] of size n by d elements.  Rotation of the above array by 2 will make array… Read More
We have introduced Linked Lists in the previous post. We also created a simple linked list with 3 nodes and discussed linked list traversal.All programs… Read More
Given an unsorted array of nonnegative integers, find a continuous subarray which adds to a given number. Examples :  Input: arr[] = {1, 4, 20, 3,… Read More
Given a linked list, find the length of the longest palindrome list that exists in that linked list.  Examples:  Input : List = 2->3->7->3->2->12->24 Output… Read More
Given a singly linked list of characters, write a function that returns true if the given list is a palindrome, else false. Recommended: Please solve… Read More
Given two strings, represented as linked lists (every character is a node in a linked list). Write a function compare() that works similar to strcmp(),… Read More
Given a linked list that is sorted based on absolute values. Sort the list based on actual values.Examples:  Input: 1 -> -10 Output: -10 ->… Read More
Given an array of random numbers, Push all the zero’s of a given array to the end of the array. For example, if the given… Read More
Given an expression string exp, write a program to examine whether the pairs and the orders of “{“, “}”, “(“, “)”, “[“, “]” are correct… Read More
Write a function to check whether two given strings are anagram of each other or not. An anagram of a string is another string that… Read More
Given a linked list of 0s, 1s and 2s, sort it.Examples: Input: 1 -> 1 -> 2 -> 0 -> 2 -> 0 -> 1… Read More
Given a linked list and two integers M and N. Traverse the linked list such that you retain M nodes then delete next N nodes,… Read More

Start Your Coding Journey Now!