Sudhir sharma has Published 1206 Articles

Ways to remove one element from a binary string so that XOR becomes zero in C++

sudhir sharma

sudhir sharma

Updated on 17-Jul-2020 11:25:29

130 Views

In this problem, we are given a binary string. Our task is to count the total number of ways in which we can remove one element such that XOR becomes zero.Let’s take an example to understand the problem, Inputn = 11010Output3to solve this problem, we need the logic that if ... Read More

Ways to select one or more pairs from two different sets in C++

sudhir sharma

sudhir sharma

Updated on 17-Jul-2020 11:23:43

110 Views

In this problem, we are given two positive numbers n and m (n > 1;       x = (1LL * x * x) % p;    }    return res; } void calculate(int n){    fact[0] = inverseMod[0] = 1;    for (int i = 1; i

Ways to sum to N using array elements with repetition allowed in C++

sudhir sharma

sudhir sharma

Updated on 17-Jul-2020 11:19:38

534 Views

In this problem, we are given an array of integers and a number N. Our task is to count the total number of ways N can be generated by adding elements of the array. All combinations and repetitions are allowed.Let’s take an example to understand the problem, Inputarr = {1, ... Read More

Ways to write N as sum of two or more positive integers in C++

sudhir sharma

sudhir sharma

Updated on 17-Jul-2020 11:16:05

313 Views

In this problem, we are given an integer n. Our task is to find the total number of ways in can be expressed as sum of two or more positive integers.Let’s take an example to understand the problem, InputN = 4Output5Explanation4 can be written as the sum in these ways, ... Read More

Write a program that does not terminate when Ctrl+C is pressed in C

sudhir sharma

sudhir sharma

Updated on 17-Jul-2020 11:12:32

227 Views

In this problem, we have to create a program that does not terminate when ctrl+C is pressed. Instead, it prints“Ctrl + C cannot terminate the program”.For this, we can use signal handling. The signal SIGINT is created on pressing ctrl+c. To solve this problem, we will catch this signal and ... Read More

Woodall Number in C++

sudhir sharma

sudhir sharma

Updated on 17-Jul-2020 11:06:50

155 Views

In this problem, we are given a number and our task is to check if the number is Woodall number or not.Woodall number is a special type of number which is of the form, Wn = n.2n -1First 5 Woodall numbers are 1, 7, 23, 63, 159Let’s take an example ... Read More

Word formation using concatenation of two dictionary words in C++

sudhir sharma

sudhir sharma

Updated on 17-Jul-2020 11:04:16

132 Views

In this problem, we are given a dictionary and a word. Our task is to check if the given wors can be formed using the concatenation of two dictionary words.While forming given words repetition of words is not legal.Let’s take an example to understand the problem, Inputdictionary = {“hello”, “tutorials”, ... Read More

Word Ladder (Length of shortest chain to reach a target word) in C++

sudhir sharma

sudhir sharma

Updated on 17-Jul-2020 11:00:30

232 Views

In this problem, we are given a dictionary and two words ‘start’ and ‘target’. Our task is to generate a chain (ladder) from start work to target word, the chain is created such that each word differs the other character by only one word and the word should also exist ... Read More

Working with Array and Vectors using STL in C++

sudhir sharma

sudhir sharma

Updated on 17-Jul-2020 10:56:51

305 Views

Array and vectors are very important data structures in competitive programming for solving problems. And the STL (Standard Template Library) in c++ programming provide some functions to perform operations of arrays and vectors.Let’s see some of these functions in action, Finding sum, Min and Max of the array/vector − In ... Read More

Working with tmux session

sudhir sharma

sudhir sharma

Updated on 17-Jul-2020 10:52:40

336 Views

Tmux is a terminal multiple for Unix OS. It provides multiple terminal sessions to its users. It is used when we are using cloud-based services (like Azure, AWS) for the creation of separate terminals for different remote users.While working with web services, one needs to create an EC2 instance on ... Read More

Advertisements