Arnab Chakraborty has Published 4452 Articles

C++ program to check xor game results 0 or not

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 07:56:00

108 Views

Suppose we have an array A with N elements and another binary string S. Consider two players are playing a game. They are numbered as 0 and 1. There is one variable x whose initial value is 0. The games has N rounds. In ith round person S[i] does one ... Read More

C++ program to concatenate strings in reverse order

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 07:52:29

447 Views

Suppose we have two strings S and T. Both are in lowercase letters. Concatenate T and S in this order to generate the final string.So, if the input is like S = "ramming"; T = "prog", then the output will be "programming"StepsTo solve this, we will follow these steps −res ... Read More

C++ program to count number of cities we can visit from each city with given operations

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 07:50:08

588 Views

Suppose we have a list of N coordinate points P in the form (xi, yi). The x and y values are permutation of first N natural numbers. For each k in range 1 to N. We are at city k. We can apply the operations arbitrarily many times. The operation: ... Read More

C++ program to count number of operations needed to reach n by paying coins

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 07:47:24

128 Views

Suppose we have five numbers, N, A, B, C, D. We start with a number 0 and end at N. We can change a number by certain number of coins with the following operations −Multiply the number by 2, paying A coinsMultiply the number by 3, paying B coinsMultiply the ... Read More

C++ program to find maximum distance between two rival students after x swaps

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 07:47:12

203 Views

Suppose we have four numbers n, x, a and b. There are n students in the row. There are two rivalling students among them. One of them is at position a and another one is at position b. Positions are numbered from 1 to n from left to right. We ... Read More

C++ program to find array after removal of left occurrences of duplicate elements

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 07:40:37

113 Views

Suppose we have an array A with n elements. We want to remove duplicate elements. We want to leave only the rightmost entry for each element of the array. The relative order of the remaining unique elements should not be changed.So, if the input is like A = [1, 5, ... Read More

C++ program to find maximum possible amount of allowance after playing the game

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 07:40:24

182 Views

Suppose we have three numbers A, B and C. Consider a game: There are three "integer panels", each with a digit form 1 to 9 (both inclusive) printed on it, and one "operator panel" with a '+' sign printed on it. The player should make a formula of the form ... Read More

C++ program to calculate how many years needed to get X rupees with 1% interest

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 07:37:50

127 Views

Suppose we have a number X. We have 100 rupees in a bank. The bank returns annual interest rate of 1 % compounded annually. (Integers only). We have to check how many years we need to get X rupees?So, if the input is like X = 520, then the output ... Read More

C++ program to find number of distinct values we can get after negating a subarray

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 07:33:05

149 Views

Suppose we have an array A with n elements. We select any subset of given numbers and negate these numbers. We have to find maximum number of different values in the array we can get.So, if the input is like A = [1, 1, 2, 2], then the output will ... Read More

C++ program to count expected number of operations needed for all node removal

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Mar-2022 07:28:50

91 Views

Suppose we have the adjacency matrix of a directed graph G. Until the graph becomes empty, we are repeating the following operation: Select one vertex from G, then erase that vertex and all vertices that are reachable from that vertex by following some edges. Erasing a vertex will also erase ... Read More

Advertisements