Sudhir sharma has Published 1149 Articles

Sum of XOR of sum of all pairs in an array in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2021 04:57:57

2K+ Views

In this problem, we are given an array arr[] of size n. Our task is to create a program to find the sum of XOR of sum of all pairs in an array.Let’s see an example to understand the problem,  Input: arr[5, 7, 9]Output: 22Explanation: (5+5) ^ (5+7) ^ (5+9) ^ (7+5) ^ ... Read More

Print all possible ways to convert one string into another string in C++

sudhir sharma

sudhir sharma

Updated on 25-Jan-2021 05:29:05

262 Views

In this problem, we are given two strings str1 and str2. Our task is to create a program to Print all possible ways to convert one string into another string. Problem Description: Here, we need to find all possible ways using which we can convert str1 to str2. While converting, we can perform ... Read More

Print BST keys in given Range - O(1) Space in C++

sudhir sharma

sudhir sharma

Updated on 25-Jan-2021 05:28:31

131 Views

In this problem, we are given two values k1 and k2 (k1 < k2), and the root of the binary search tree. Our task is to create a program to Print BST keys in given Range. Problem Description: We will print all the keys of the tree from n1 to n2 in ... Read More

Print cells with same rectangular sums in a matrix in C++

sudhir sharma

sudhir sharma

Updated on 25-Jan-2021 05:28:12

132 Views

In this problem, we are given a matrix mat of size mXn of integer values. Our task is to create a program to Print cells with same rectangular sums in a matrix.Problem description: We will be finding a cell in the matrix in such a way that the sum of sub-matrices ... Read More

Find maximum average subarray of k length in C++

sudhir sharma

sudhir sharma

Updated on 25-Jan-2021 05:25:01

172 Views

In this problem, we are given an array arr[] of size n consisting of positive and negative values and an integer k. Our task is to find the maximum average subarray of k length. Let’s take an example to understand the problem,  Input: arr[] = {4, -1, 5, 6, -2, 4} k ... Read More

Find maximum in an array without using Relational Operators in C++

sudhir sharma

sudhir sharma

Updated on 25-Jan-2021 05:24:40

271 Views

In this problem, we are given an array arr[] of size n consisting of positive values. Our task is to find maximum in an array without using Relational Operators. Let’s take an example to understand the problem, Input: arr[] = {5, 1, 6, 7 , 8, 2}Output: 8Solution ApproachSince we need to ... Read More

Find maximum among x^(y^2) or y^(x^2) where x and y are given in C++

sudhir sharma

sudhir sharma

Updated on 25-Jan-2021 05:22:01

127 Views

In this problem, we are given two values x and y. Our task is to find maximum among x^(y^2) or y^(x^2) where x and y are given. Let’s take an example to understand the problem,  Input: x = 4, y = 3Output: 3^(4^2)Explanation: x^(y^2) = 4^(3^2) = 4^9 = 262144y^(x^2) = 3^(4^2) = 3^16 ... Read More

Find maximum among all right nodes in Binary Tree in C++

sudhir sharma

sudhir sharma

Updated on 25-Jan-2021 05:21:35

104 Views

In this problem, we are given a Binary Tree. Our task is to find maximum among all right nodes in Binary Tree. Problem Description: Here, we need to find the maximum value amongst all right child nodes of the binary Tree.Let’s take an example to understand the problem,  Input: Output: 9Explanation: All right nodes are: ... Read More

Find maximum (or minimum) sum of a subarray of size k in C++

sudhir sharma

sudhir sharma

Updated on 25-Jan-2021 05:21:14

409 Views

In this problem, we are given an  array arr[] and a number k. Our task is to Find the maximum (or minimum) sum of a subarray of size k. Let’s take an example to understand the problem,  Input: arr[] = {55, 43, 12, 76, 89, 25, 99} , k = 2Output: 165Explanation:The subarray ... Read More

Find maximum (or minimum) in Binary Tree in C++

sudhir sharma

sudhir sharma

Updated on 25-Jan-2021 05:20:42

1K+ Views

In this problem, we are given a binary tree. Our task is to Find maximum (or minimum) in Binary Tree. Problem Description: We need to find the nodes of the binary tree that have maximum and minimum value in the binary tree.Let’s take an example to understand the problem,  Input: Output: max = 9 ... Read More

Advertisements