Sudhir sharma has Published 1149 Articles

Print all the levels with odd and even number of nodes in it in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 10:09:56

207 Views

In this problem, we are given a tree. And we have to print all the levels with even number of nodes and odd number of nodes in it.Let’s take an example to understand the concept betterOutput −Levels with odd number of nodes: 1, 3, 4 Levels with even number of ... Read More

Print all the pairs that contains the positive and negative values of an element in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 09:58:19

209 Views

In this problem, we are given an array of unique integers. And we have to return all pairs of integers(positive and negative integers) that are present in the array.Let’s take an example to understand the problem better −Input: array = {1 , 4 , 7 , -1, 2, 5, -7} ... Read More

Print all the palindromic permutations of given string in alphabetic order in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 09:57:09

296 Views

In this problem, we are given a string of size n. And we have to print all possible palindromic permutation that can be generated using the characters of the string in alphabetical order. If palindrome is not created using the string print ‘-1’.Let’s take an example to understand the topic ... Read More

Print all the paths from root, with a specified sum in Binary tree in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 09:53:32

189 Views

In this problem, we are given a Binary tree and a sum S. And we have to find the path starting from root to any node of the tree, which gives the sum equal to the given sum.InputSum = 14 Output : path : 4 10 4 3 7To find ... Read More

Print all triplets with given sum in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 09:48:03

275 Views

In this problem, we are given an array of unique integers and a sum. And we have to find the triplets which can form the same sum.Let's take an example to solve the problem −Input : array = {0 , 2 , -1 , 1, -2} Sum = 1 Output ... Read More

Print all the sum pairs which occur maximum number of times in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 09:42:13

169 Views

In this problem, we are given an array of n unique integers. And we have to find the sum of two integers of the array which has the maximum frequency. The problem has multiple solutions and you need to find them all.Input : array = { 1, 12, 5, 7, ... Read More

Print all triplets in sorted array that form AP in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 09:39:52

225 Views

In this problem, we are given a sorted array of numbers and we need to find the triplets with are in the form of arithmetic progression.An arithmetic progression is a series of numbers in which the difference between consecutive terms is the same.Let’s take an example to understand the problem ... Read More

Print all paths from top left to bottom right in a matrix with four moves allowed in C++

sudhir sharma

sudhir sharma

Updated on 16-Jan-2020 12:39:11

263 Views

In this problem, we are given an mXn 2D matrix and we have to print all possible paths from top left to bottom right of matrix. For traversal, we can move in all four directions i.e. left, right, top, bottom.Thought the moves right and top are rarely used but these ... Read More

Print all permutations in sorted (lexicographic) order in C++

sudhir sharma

sudhir sharma

Updated on 16-Jan-2020 12:29:24

537 Views

In this problem, we are given a string of length n and we have to print all permutations of the characters of the string in sorted order.Let’s take an example to understand the problem :Input: ‘XYZ’Output: XYZ, XZY, YXZ, YZX, ZXY, ZYX.Here we have to print all permutations in lexicographical ... Read More

Print all valid words that are possible using Characters of Array in C++

sudhir sharma

sudhir sharma

Updated on 03-Jan-2020 10:13:33

242 Views

Ib this problem, we are given a set of words and an array of character and we have to check if the words are possible using the characters of the array.Let’s take an example to understand the problem better −Input : words[] : {‘go’ , ‘hi’ , ‘run’ , ‘on’ ... Read More

Advertisements