Arnab Chakraborty has Published 4282 Articles

Find middle of singly linked list Recursively in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 10:26:31

551 Views

Consider we have a list of numbers; our task is to find the middle of the linked list using recursion. So if the list elements are [12, 14, 18, 36, 96, 25, 62], then the middle element is 36.To solve this problem, we will count total number of nodes in ... Read More

Find maximum element of each row in a matrix in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 10:23:30

739 Views

Consider we have a matrix, our task is to find the maximum element of each row of that matrix and print them. This task is simple. For each row, reset the max, and find the max element, and print it. Let us see the code for better understanding.Example#include #define MAX ... Read More

Find maximum element of each column in a matrix in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 10:21:54

605 Views

Consider we have a matrix, our task is to find the maximum element of each column of that matrix and print them. This task is simple. For each column, reset the max, and find the max element, and print it. Let us see the code for better understanding.Example#include #define MAX ... Read More

Find last index of a character in a string in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 10:19:59

698 Views

Suppose we have a string str. We have another character ch. Our task is to find the last index of ch in the string. Suppose the string is “Hello”, and character ch = ‘l’, then the last index will be 3.To solve this, we will traverse the list from right ... Read More

Find last element after deleting every second element in array of n integers in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 10:12:04

536 Views

Consider we have one circular array containing integers from 1 to n. Find the last element, that would remain in the list after deleting every second element starting from first element. If the input is 5, then array will be [1, 2, 3, 4, 5]. Start from 1. After deleting ... Read More

Find largest element from array without using conditional operator in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 10:07:30

311 Views

Suppose we have an array A with some elements. We have to find the largest element in the array A, but the constraint is, we cannot use any conditional operator. So if A = [12, 63, 32, 24, 78, 56, 20], then maximum element will be 78.To solve this problem, ... Read More

Find k closest numbers in an unsorted array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 10:06:33

508 Views

Consider we have an array A with few elements. The array is unsorted. We have two other value X and k. Our task is to find the k number of nearest elements of X from the array A. If the element X is present in the array, then it will ... Read More

Find k closest elements to a given value in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 10:00:58

197 Views

Consider we have an array A with few elements. We have two other value X and k. Our task is to find the k number of nearest elements of X from the array A. If the element X is present in the array, then it will not be shown in ... Read More

Find if n can be written as product of k numbers in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 09:57:45

186 Views

Suppose we have a number N. We have another number k. We have to check the number can be represented using k numbers or not. Suppose a number 54, and k = 3, then it will print the numbers like [2, 3, 9], if it cannot be represented, then print ... Read More

Find if array can be divided into two subarrays of equal sum in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 09:54:12

200 Views

Suppose we have an array A. We have to check whether we can split the array into two parts, whose sum are equal. Suppose the elements are [6, 1, 3, 2, 5], then [6, 1], and [2, 5] can be two subarrays.This problem can be solved easily by following these ... Read More

Advertisements