Arnab Chakraborty has Published 4293 Articles

C++ code to check pile count is valid from second day

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:35:35

205 Views

Suppose we have two arrays X and Y of same size. There are stone piles with X[i] number of stones on ith index on the first day and on the second day ith index has Y[i] number of stones. On the first day many members have come. Either they do ... Read More

C++ code to find minimum k to get more votes from students

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:33:28

243 Views

Suppose we have an array A with n elements. There are n students in a school and each of them has exactly k votes and all votes should be used. There are two parties. The A[i] represents ith student has given A[i] amount of votes to first party and this ... Read More

C++ code to check triangular number

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:31:34

1K+ Views

Suppose we have a number n. We have to check whether the number is triangular number or not. As we know, if n dots (or balls) can be arranged in layers to form a equilateral triangle then n is a triangular number.So, if the input is like n = 10, ... Read More

C++ code to find corrected text after double vowel removal

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:27:52

166 Views

Suppose we have a string S with n character. On a text editor, there is a strange rule. The word corrector of this text editor works in such a way that as long as there are two consecutive vowels in the word, it deletes the first vowel in a word. ... Read More

C++ code to count steps to reach final position by robot

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:24:46

377 Views

Suppose we have two coordinates (x1, y1) and (x2, y2). A robot is at the point (x1, y1) and wants to go to the point (x2, y2). In a single step, the robot can move towards one cell to its 8 adjacent coordinates. We have to find minimal number of ... Read More

C++ code to count numbers after division elements greater than half of array size

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:20:32

162 Views

Suppose we have an array A with n elements. We have to find some non-zero integer d, such that such that, after each number in the array is divided by d, the number of positive values that are presented in the array is greater than or equal to the half ... Read More

C++ code to find who cannot give sufficient candies

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:17:25

160 Views

Suppose we have two numbers a and b. There are a and b number of candies in Amal's and Bimal's hand. Amal offered 1 candy to Bimal and Bimal gave two candies to Amal, in the next turn Amal gave 3 candies and Bimal gave 4 and so on. This ... Read More

C++ code to find minimum number starting from n in a game

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:12:58

229 Views

Suppose we have a number n. In a game initially the value of n is v and the player is able to do the following operation zero or more times: Select a positive integer x that x < n and x is not a divisor of n, then subtract x ... Read More

C++ code to find money after buying and selling shares

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:11:01

325 Views

Suppose we have two arrays A of size n, and B of size m, and another number r. There are n opportunities to buy shares. The i-th of them allows to buy as many shares as we want, ith share price is A[i]. And also there are m opportunities to ... Read More

C++ code to find array from given array with conditions

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Mar-2022 11:07:41

142 Views

Suppose we have an array A with n elements. There is another hidden array B of size n. The elements can be negative or positive. For each index i in range 1 to n, following operations will be performed −Set A[i] as 0 initiallyThen add B[i] to A[i], subtract B[i+1], ... Read More

Advertisements