Sudhir sharma has Published 1149 Articles

Print Concatenation of Zig-Zag String in n Rows in C++

sudhir sharma

sudhir sharma

Updated on 03-Jan-2020 07:53:34

405 Views

In this problem, we are given a string that is a sequence of characters. And we are given the length of the zig-zag pattern and we have to print the concatenation string of this zig-zag string in n rows.Let’s see a few examples to understand the concept better, EXAMPLEInput : ... Read More

Print concentric rectangular pattern in a 2d matrix in C++

sudhir sharma

sudhir sharma

Updated on 03-Jan-2020 07:50:37

871 Views

In this problem, we have to print a rectangular pattern in a 2D matrix in such a way that they are concentric to each other.Let’s take an example to understand this problem better, For n=4 is :    4 4 4 4 4 4 4    4 3 3 3 ... Read More

Print consecutive characters together in a line in C++

sudhir sharma

sudhir sharma

Updated on 03-Jan-2020 07:47:02

297 Views

In this problem, we are given a string of characters and we have to print the same string in such a way that if two or more characters are consecutive then print them together in a single line otherwise print them in different lines i.e. with a line break.Let’s take ... Read More

Print cousins of a given node in Binary Treein C++

sudhir sharma

sudhir sharma

Updated on 03-Jan-2020 07:42:50

246 Views

Binary Tree is a special tree whose every node has at max two child nodes. So, every node is either a leaf node or has one or two child nodes.Example, In this problem, we are given a binary tree and we have a node of the tree and we have ... Read More

Print digit’s position to be removed to make a number divisible by 6 in C++

sudhir sharma

sudhir sharma

Updated on 03-Jan-2020 07:32:06

257 Views

In this problem, we are given number and we have to remove more digit from the number. So that the new number formed after removal is divisible by 6.Let’s take an example to learn the concept better −Input : 1324 Output : 4Explanation − on removing the 4th number we ... Read More

Print direction of moves such that you stay within the [-k, +k] boundary in C++

sudhir sharma

sudhir sharma

Updated on 03-Jan-2020 07:27:50

194 Views

In this problem, we have to find a valid way to move positive direction or negative direction in such a way that we stay within a certain limit that is provided by the user.Here, We are given a certain maximum limit K, which is the maximum value to which we ... Read More

Print distinct sorted permutations with duplicates allowed in input in C++

sudhir sharma

sudhir sharma

Updated on 03-Jan-2020 07:24:47

755 Views

In this programming problem, we are given a string and we have to print the distinct sorted permutations of the string elements that can be formed. The condition with this problem is that the string may contain a character that will arise more than one time. Also, the given string ... Read More

C Program for Activity Selection Problem

sudhir sharma

sudhir sharma

Updated on 03-Jan-2020 07:08:44

6K+ Views

The activity selection problem is a problem in which we are given a set of activities with their starting and finishing times. And we need to find all those activities that a person can do performing the single activity at a time.The greedy algorithm is appointed in this problem to ... Read More

C / C++ Program for Subset Sum (Backtracking)

sudhir sharma

sudhir sharma

Updated on 03-Jan-2020 07:05:07

12K+ Views

Backtracking is a technique to solve dynamic programming problems. It works by going step by step and rejects those paths that do not lead to a solution and trackback (moves back ) to the previous position.In the subset sum problem, we have to find the subset of a set is ... Read More

Binomial Random Variables in C++

sudhir sharma

sudhir sharma

Updated on 03-Jan-2020 07:01:33

440 Views

Random variables are those variables that are an outcome of the outcomes of a process that has the probability of giving rise to multiple outcomes. For example, The variable denoting head or tail as an outcome on tossing a coin is a random variable.A binomial random variable is a special ... Read More

Advertisements