Sudhir sharma has Published 1206 Articles

Find row with maximum sum in a Matrix in C++

sudhir sharma

sudhir sharma

Updated on 16-Mar-2021 06:09:04

907 Views

In this problem, we are given a matrix mat[][] of size N*N. Our task is to Find the row with maximum sum in a Matrix.Let’s take an example to understand the problem, Inputmat[][] = {    8, 4, 1, 9    3, 5, 7, 9    2, 4, 6, 8 ... Read More

Find row number of a binary matrix having maximum number of 1s in C++

sudhir sharma

sudhir sharma

Updated on 16-Mar-2021 06:05:13

115 Views

In this problem, we are given a binary matrix in which each row is sorted. Our task is to Find row number of a binary matrix having the maximum number of 1s.Let’s take an example to understand the problem, InputbinMat[][] = {    1, 1, 1, 1    0, 0, ... Read More

Find right sibling of a binary tree with parent pointers in C++

sudhir sharma

sudhir sharma

Updated on 16-Mar-2021 05:58:28

173 Views

In this problem we are given a binary tree and parent pointers. Our task is to Find right sibling of a binary tree with parent pointers.Let’s take an example to understand the problem, InputNode = 3Output7Solution ApproachA simple solution to the problem is finding the leaf node of the nearest ... Read More

Find Pth term of a GP if Mth and Nth terms are given in C++

sudhir sharma

sudhir sharma

Updated on 16-Mar-2021 05:49:41

104 Views

In this problem we are given five values m, n, mth term, nth term, p. Our task is to Find Pth term of a GP if Mth and Nth terms are given.For a GP, we are given the values of mth term and nth term. Using these values, we need ... Read More

Find probability that a player wins when probabilities of hitting the target are given in C++

sudhir sharma

sudhir sharma

Updated on 16-Mar-2021 05:47:04

130 Views

In this problem we are given four values p, q, r, s. Our task is to Find probability that a player wins when probabilities of hitting the target are given.Here, we have two players who are playing a game of archery. And the probability of player 1 hitting the target ... Read More

Find power of power under mod of a prime in C++

sudhir sharma

sudhir sharma

Updated on 16-Mar-2021 05:44:30

479 Views

In this problem we are given four values A, B, C, M(a prime number). Our task is to Find power of power under mod of a prime.We simply need to find the value of (A ^ (B ^ C)) (mod M).Let’s take an example to understand the problem, InputA = ... Read More

Find postorder traversal of BST from preorder traversal in C++

sudhir sharma

sudhir sharma

Updated on 16-Mar-2021 05:31:46

1K+ Views

In this problem we are given an array preOrder[] that represents the preorder traversal of the binary search tree. Our task is to Find postorder traversal of BST from preorder traversal.Let’s take an example to understand the problem, InputpreOrder[] = {5, 2, 4, 7, 12}Output{4, 2, 12, 7, 5}Solution ApproachA ... Read More

Find position of the only set bit in C++

sudhir sharma

sudhir sharma

Updated on 16-Mar-2021 05:19:25

921 Views

In this problem we are given a number N which has only one set bit in its binary representation. Our task is to find the position of the only set bit. If the number has only one set bit return the position of the number otherwise print invalid number.Let’s take ... Read More

Find position of the given number among the numbers made of 4 and 7 in C++

sudhir sharma

sudhir sharma

Updated on 16-Mar-2021 05:15:10

315 Views

In this problem we are given a number N. Our task is to Find position of the given number among the numbers made of 4 and 7. The series consisting of 4 and 7 only is 4, 7, 44, 47, 74, 77, 444….Let’s take an example to understand the problem, ... Read More

Find position of left most dis-similar bit for two numbers in C++

sudhir sharma

sudhir sharma

Updated on 16-Mar-2021 05:13:08

144 Views

In this problem we are given two numbers, num1 and num2. Our task is to find the position of the leftmost dis-similar bit for two numbers. We need to print the first bit which is not the same for both numbers in their respective binary representation. The length of both ... Read More

Advertisements