Arnab Chakraborty has Published 4293 Articles

C++ program to find out the number of pairs in an array that satisfy a given condition

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Mar-2022 07:50:50

2K+ Views

Suppose, we are given n numbers in array nums. We have to choose a pair of two numbers from the array, and there is a condition that the difference of their positions in the array is equal to the sum of the two numbers. There can be a total of ... Read More

C++ Program to check if given numbers are coprime or not

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Mar-2022 07:47:17

2K+ Views

Suppose, we have n integers in an array nums. We have to find out if the numbers in the array are pairwise coprime, setwise coprime, or not coprime.Two numbers nums[i] and nums[j] are said to be pairwise coprime if gcd(nums[i], nums[j]) = 1. This should hold for every number pair ... Read More

C++ Program to check if two stacks of letters can be emptied or not

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Mar-2022 07:41:49

177 Views

Suppose, there are 2n number of letters and each of them has an integer number between 1 to n written on them. There are exactly two letters that have the same number written on them. These letters are arranged into m stacks and stack i has letters stack[i] on it. ... Read More

C++ Program to find out the maximum amount of money that can be made from selling cars

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Mar-2022 07:17:43

300 Views

Suppose, there is a demand for red and blue cars for sale. An automobile company decides to sell p red cars and q blue cars of different prices. Currently, the company has 'a' number of red cars, 'b' number of blue cars, and 'c' numbers of colorless cars (the cars ... Read More

C++ program to check if two images match after rotation and translation

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Mar-2022 07:09:04

241 Views

Suppose, there are two n * n pixel square images first and second. The pixels can either be black or white. The images are given in a matrix representation where if a pixel is black it is represented as 'x' and if it is white, it is represented as '.'. ... Read More

C++ Program to find out the maximum amount of score that can be decreased from a graph

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Mar-2022 06:59:39

325 Views

Suppose, there is a weighted, undirected graph that has n vertices and m edges. The score of the graph is defined as the addition of all the edges weights in the graph. The edge weights can be negative, and if they are removed the score of the graph increases. What ... Read More

C++ Program to find out the number of cells to block in a grid to create a path

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Mar-2022 06:54:00

412 Views

Suppose, there is a grid of dimensions h * w. There is a robot in cell position (0, 0) and it has to go to the position (h - 1, w - 1). There are two types of cells in a grid, blocked and unblocked. The robot can pass through ... Read More

C++ to perform certain operations on a sequence

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Mar-2022 06:47:04

421 Views

Suppose, we are given an empty sequence and n queries that we have to process. The queries are given in the array queries and they are in the format {query, data}. The queries can be of the three following types−query = 1: Add the supplied data to the end of ... Read More

C++ Program to find out the maximum number of moves to reach a unblocked cell to another unblocked cell in a grid

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Mar-2022 06:37:29

319 Views

Suppose, we are given a grid of dimensions h * w that contains two types of cells, blocked and unblocked. Blocked cells mean that the cells aren't accessible and unblocked means that the cells are accessible. We represent the grid in a 2D array where the blocked cells are given ... Read More

C++ Program to check cats words are right or not with colored hats

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Feb-2022 13:16:39

192 Views

Suppose we have an array A with N elements. Consider there are N cats and they are numbered from 1 to N. Each cat is wearing a hat and ith cat says "there are exactly A[i] number of different colors among the N-1 hats owned by the cats except me". ... Read More

Advertisements