Skip to content

Category Archives: C++ Programs

Write a function that takes a list sorted in non-decreasing order and deletes any duplicate nodes from the list. The list should only be traversed… Read More
We have discussed Insertion Sort for arrays. In this article we are going to discuss Insertion Sort for linked list. Below is a simple insertion sort… Read More
Given an array that contains both positive and negative integers, find the product of the maximum product subarray. Expected Time complexity is O(n) and only… Read More
Prerequisite: How to return multiple values from a function in C or C++? There are often cases of using return statements while dealing with function calls.… Read More
Given an array, cyclically rotate the array clockwise by one.  Examples:   Input: arr[] = {1, 2, 3, 4, 5} Output: arr[] = {5, 1, 2,… Read More
Given two matrices, the task to multiply them. Matrices can either be square or rectangular. Examples:  Input : mat1[][] = {{1, 2}, {3, 4}} mat2[][]… Read More
We have discussed flattening of a multi-level linked list where nodes have two pointers down and next. In the previous post, we flattened the linked… Read More
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… Read More
Write a function AlternatingSplit() that takes one list and divides up its nodes to make two smaller lists ‘a’ and ‘b’. The sublists should be… Read More
The Checksum is an error detection method that detected errors in data/message while it is transmitted from sender to receiver. This method is used by… Read More
Given an array of DISTINCT elements, rearrange the elements of array in zig-zag fashion in O(n) time. The converted array should be in form a… Read More
Given a Linked List of integers, write a function to modify the linked list such that all even numbers appear before all the odd numbers… Read More
Write a function that moves the last element to the front in a given Singly Linked List. For example, if the given Linked List is… Read More
Given a Doubly Linked List, the task is to reverse the given Doubly Linked List. See below diagrams for example.  (a) Original Doubly Linked List… Read More
Given a singly linked list, remove all the nodes which have a greater value on the right side.  Examples:  Input: 12->15->10->11->5->6->2->3->NULL Output: 15->11->6->3->NULL Explanation: 12,… Read More

Start Your Coding Journey Now!