Sudhir sharma has Published 1206 Articles

Print a matrix in a spiral form starting from a point in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2020 06:34:01

147 Views

In this problem, we are a 2d matrix and a point P(c, r). Our task is to print all elements of the matrix in a spiral form (anti-clockwise) that starts from a given point P.Let’s take an example to understand our problem, Input: matrix[][] = {{3, 5, 7} } Output:To ... Read More

Print a matrix in alternate manner (left to right then right to left) in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2020 06:31:54

352 Views

In this problem, we are given a 2D array. Our task is to print all the elements of the array starting from the first row, from left to right, then right to left in the next row and again from left to right and so on.Let’s take an example to ... Read More

Print a matrix in Reverse Wave Form in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2020 06:29:07

340 Views

In this problem, we are given a matrix. Our task is to print the matrix in reverse waveform in a single line.This example will make the problem clear, Input:    1 4 6 11    2 5 8 54    7 9 3 43    1 7 4 34 Output: ... Read More

Print a number containing K digits with digital root D in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2020 06:26:20

75 Views

In this problem, we are given two numbers K and D. Our task is to print a number of k digits and which has digital root equal to D.Digital Root is a single-digit value which is the result of the recursive addition of the digits of the number till the ... Read More

Print a number strictly less than a given number such that all its digits are distinct in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2020 06:24:36

225 Views

In this problem, we are given a number n. Our task is to print the largest number less than n such that all its digits are distinct.Let’s take an example to understand the problemInput: n = 2332 Output: 2319To solve this problem, we reverse the count of the numbers i.e. ... Read More

Print a pattern without using any loop in C++

sudhir sharma

sudhir sharma

Updated on 22-Jan-2020 12:44:25

547 Views

In this problem, we are given a number n. Our task is to print patterns with decreasing to 0 or negative then increasing back to the number.Let’s take an example to understand the problem, Input: n = 12 Output: 12 7 2 -3 2 7 12To solve this problem, we ... Read More

Print a String in wave pattern in C++

sudhir sharma

sudhir sharma

Updated on 22-Jan-2020 12:42:59

389 Views

In this problem, we are given a string and an integer n. Our task is to print the given string in a wave pattern of n lines.Let’s take an example to understand the problem, Input: Tutorial n = 3 Output: T             r    U ... Read More

Print all 3 digit repeating numbers in a very large number in C++

sudhir sharma

sudhir sharma

Updated on 22-Jan-2020 12:38:07

215 Views

In this problem, we are given a number. And we have to print all 3 digit repeating numbers.Let’s take an example to understand the problem, Input: 98769876598765 Output:    987: 3 times    876: 3 times    765: 2 timesTo solve this problem, we will use the large number which ... Read More

Print all combinations of balanced parentheses in C++

sudhir sharma

sudhir sharma

Updated on 22-Jan-2020 12:36:07

643 Views

In this problem, we are given an integer n. Our task is to print all possible pairs of n balanced parentheses.Balanced parentheses are parentheses pairs that have a closing symbol for every corresponding opening symbol. Also, pairs should be properly nested.Let’s take an example to understand the problem, Input: n ... Read More

Print all combinations of factors in C++

sudhir sharma

sudhir sharma

Updated on 22-Jan-2020 12:33:42

188 Views

In this problem, we are given a number n. Our task is to print all combinations of factors of n.Let’s take an example to understand the topic better −Input: 24 Output: 2 2 2 3 2 4 3 8 3 4 6 2 12For this, we will use recursion function ... Read More

Advertisements