Arnab Chakraborty has Published 4293 Articles

Find most significant set bit of a number in C++

Arnab Chakraborty

Arnab Chakraborty

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

2K+ Views

Here we will see if a number is given, then how to find the value of Most Significant Bit value, that is set. The value is power of 2. So if the number is 10, MSB value will be 8.We have to find the position of MSB, then find the ... Read More

Find middle of singly linked list Recursively in C++

Arnab Chakraborty

Arnab Chakraborty

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

529 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

704 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

578 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

654 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

522 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

289 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

487 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

183 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

179 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

Advertisements