Sudhir sharma has Published 1149 Articles

Print all possible combinations of r elements in a given array of size n in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:42:28

2K+ Views

In this problem, we are given an array of size n and a positive integer r. Our task is to print all possible combinations of the elements of the array of size r.Let’s take an example to understand the problem −Input: {5, 6, 7, 8} ; r = 3 Output ... Read More

Print all possible expressions that evaluate to a target in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:38:28

307 Views

In this problem, we are given a string of integers from 0 to 9 and a target value. We have to print out ways in which we can generate expression using +, -, and * operation which is evaluated to the value equal to target.Let’s take an example to understand ... Read More

Print all possible paths from top left to bottom right of a mXn matrix in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:36:41

367 Views

In this problem, we are given an mXn 2D matrix and we have to print all possible paths from top left to the bottom right of the matrix. For traversal, we can move only right and down in the matrix.Let’s take an example to understand the topic better −Input: 1 ... Read More

Print all possible strings of length k that can be formed from a set of n characters in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:35:01

2K+ Views

In this problem, we are given a set of characters and a positive integer k and we have to print all possible strings of length k that can be generated using the characters of the set.Let’s take an example to understand the problem better −Input: set = {‘x’, ‘y’, ‘z’} ... Read More

Print all possible strings that can be made by placing spaces in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:31:08

388 Views

In this problem, we are given a string and we have to print all those string that can be made using this string by placing space in between the characters of the string.Let’s take an example to understand the topic better −Input: string = ‘XYZ’ Output: XYZ, XY Z, X ... Read More

Print all possible sums of consecutive numbers with sum N in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:30:24

517 Views

In this problem, we are given a positive integer N and we have to print the sequence of all possible consecutive numbers with a sum equal to N.Let’s take an example to understand the problem, Input: N = 15 Output: 1 2 3 4 5 7 8A simple solution to ... Read More

Print all possible words from phone digits in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:23:51

862 Views

In this problem, we are given a number and we have to print all words that can be formed by pressing those words in an old fashioned mobile keyboard.We are quite familiar with the QWERTY keyboard style that we use today. But before the invention of QWERTY keypad phones were ... Read More

Print all prime factors and their powers in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:16:29

703 Views

In this problem, we are given a number N, and we have to find all unique prime factors and their powers that divide the number.Let’s take an example to understand the topic −Input: 55 Output: 5 power 1 11 power 1Explanation −55 is divisible by 5 and 11.To solve this ... Read More

Print all prime numbers less than or equal to N in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:13:55

1K+ Views

In this problem, we are given a number N and we have to print all prime numbers less than or equal to N.Let’s take an example to understand the topic better −Input: 10 Output: 2 3 5 7A prime number is a number that can be divided by only one ... Read More

Print all Prime Quadruplet of a number less than it in C++

sudhir sharma

sudhir sharma

Updated on 17-Jan-2020 11:12:58

179 Views

In this problem, we are given a positive integer N, and we have to print all prime quadruplet less than or equal to n.Prime quadruplets are the set of four prime numbers calculated as {p, p+2, p+6, p+8}. Example − 5 7 11 13.Let’s take an example to understand the ... Read More

Advertisements