Sudhir sharma has Published 1149 Articles

Find size of the largest ‘+’ formed by all ones in a binary matrix in C++

sudhir sharma

sudhir sharma

Updated on 16-Mar-2021 06:26:29

228 Views

In this problem, we are given an NxN binary matrix bin[][]. Our task is to find the size of the largest ‘+’ formed by all ones in a binary matrix.Let’s take an example to understand the problem, Input0 1 1 1 1 1 0 1 0Output5Solution ApproachA simple solution to ... Read More

Find single in an array of 2n+1 integer elements in C++

sudhir sharma

sudhir sharma

Updated on 16-Mar-2021 06:22:50

302 Views

In this problem, we are given an array consisting of (2n+ 1) integer values. Out of all these values, n elements appear twice in the array and there is only one element in the array that appears once. Our task is to Find single in an array of 2n+1 integer ... Read More

Find shortest unique prefix for every word in a given list in C++

sudhir sharma

sudhir sharma

Updated on 16-Mar-2021 06:19:50

221 Views

In this problem, we are given an array of words arr[]. Our task is to find the shortest unique prefix for every word in the given list.Let’s take an example to understand the problem, Inputarr[] = {“learn”, “programming”, “code”}Outputc leap lear pSolution ApproachA simple solution to the problem is by ... Read More

Find shortest safe route in a path with landmines in C++

sudhir sharma

sudhir sharma

Updated on 16-Mar-2021 06:17:01

896 Views

In this problem, we are given a matrix mat[][]. It defines a path with landmines which are marked as 0. Our task is to Find shortest safe route in a path with landmines.While traversing through the safe path, we need to avoid walking adjacent cells of the landmine (left, right, ... Read More

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

sudhir sharma

sudhir sharma

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

1K+ 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

188 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

290 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

244 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

187 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

558 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

Advertisements