Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 269 of 377

C++ Program to find out the minimum difference value in n integer pairs

Arnab Chakraborty
Arnab Chakraborty
Updated on 02-Mar-2022 307 Views

Suppose, we are given two arrays a and b that have a total of n and m values in them respectively. We have to make n or m number of pairs (whichever is minimum) using values from the two arrays. A pair must contain a value from array a and another one from array b. We have to make the pairs in such a way so that the difference of the value in the pairs is minimum and the same. We print the value as output.So, if the input is like n = 4, m = 4, a = {2, ...

Read More

C++ Program to find out the sum of shortest cost paths for all given triplets

Arnab Chakraborty
Arnab Chakraborty
Updated on 02-Mar-2022 360 Views

Suppose, there are n cities and m roads between the cities. The m roads are given to us in an array of roads where the roads are in the format {aource, destination, weight}. Now, we define a triplet (s, t, k) where s, t, and k are cities. Now we have to calculate the minimum time needed to get from city s to city t. To visit t from s, only cities within 1 to k can be visited. If city t is unreachable from s, then we return 0. We have to calculate the minimum time for all triplets ...

Read More

C++ program to find out the shortest cost path in a given graph for q queries

Arnab Chakraborty
Arnab Chakraborty
Updated on 02-Mar-2022 610 Views

Suppose, we are given a graph that contains n vertices and is minimally connected. The edges are given to us an array where the edges are given in a {source, dest, weight} format. Now, we are given q number of queries where each query is of the format {source, destination}. We have to find the shortest cost path from the source to the destination via vertex k. We print the cost of the path for each query.So, if the input is like n = 6, q = 3, k = 1, edges = {{1, 2, 2}, {1, 3, 4}, {3, ...

Read More

C++ Program to find out the number of operations to maximize the number of even-numbered cells in a grid

Arnab Chakraborty
Arnab Chakraborty
Updated on 02-Mar-2022 202 Views

Suppose, we are given a grid of dimensions h * w. Every cell in the grid has a specific value assigned to it. We have to maximize the cells having an even value. To do that, we can select a cell that has not been selected before, and then decrease the value by 1 of the current cell and increase the value by 1 of another cell that is located vertically or horizontally adjacent to the current cell. We print out the number of operations and the cell numbers of the increase and decrease operations. The output will be in ...

Read More

C++ program to find out the number of ways a grid with boards can be colored

Arnab Chakraborty
Arnab Chakraborty
Updated on 02-Mar-2022 432 Views

Suppose, we are given a grid that has 2 rows and n columns. The grid has to be covered by n boards without one board getting over another. Now, the boards have to be colored by any one color between red, blue, and green. Two boards that are adjacent to each other cannot be colored by the same color and if not necessary, all colors do not have to be used. The configuration of the grid is given in the array 'grid', where a particular board in the grid is represented using the same English letter and different boards are ...

Read More

C++ Program to find out the super vertices in a graph

Arnab Chakraborty
Arnab Chakraborty
Updated on 02-Mar-2022 335 Views

Suppose, we are given a graph that has n vertices. The vertices are numbered 1 to n, and they are connected by the edges given in the array 'edges'. Each vertex has an 'x' value within a number from 1 to n that is given in the array 'values'. Now, we have to find out the super vertices from the graph. A vertex i is called a 'super vertex' whenever the shortest path from vertex 1 to i doesn't have a vertex with the same 'x' value as the i-th vertex. We print out all the vertices satisfying this criterion.So, ...

Read More

C++ program to find out the number of iterations needed to convert all cells to black

Arnab Chakraborty
Arnab Chakraborty
Updated on 02-Mar-2022 296 Views

Suppose, we are given a grid that contains two types of cells; black cells, and white cells. The black cells are represented as '#' and the white cells are represented as '.'. The grid is given to us in an array of strings. Now, we have to perform the following.We convert each white cell to black that has a side shared with a black cell. We perform this operation until every cell of the grid is black.We count the number of iterations it takes to convert all cells of the grid to black. The grid at the start must contain ...

Read More

C++ program to find out the center coordinates and the height of a building

Arnab Chakraborty
Arnab Chakraborty
Updated on 02-Mar-2022 351 Views

Suppose, there is a building that has center coordinates xc, yc, and height h. We don't know the center coordinates of the building, but we are provided with n pieces of information that contain x and y coordinates and an altitude value a. The altitude of coordinates (x, y) is the maximum of (h - |x - xc| - |y - yc|, 0). We have to find out the center coordinates and the height of the building. The coordinate xi is given in the array x, yi is given in teg array y, and ai is given in array a.So, ...

Read More

C++ program to find out the maximum possible tally from given integers

Arnab Chakraborty
Arnab Chakraborty
Updated on 02-Mar-2022 429 Views

Suppose, we are given two integers n and m and there are k tuples of integers that contain four integer numbers {ai, bi, ci, di}. Four arrays a, b, c, d are given, and a[i] signifies the i-th tuple's a value. Now, let us consider a sequence dp that has n positive integers and 1

Read More

C++ program to find out the minimum amount of time needed to reach from source to destination station by train

Arnab Chakraborty
Arnab Chakraborty
Updated on 02-Mar-2022 501 Views

Suppose n stations are connected by m tracks. The stations are named from 1 to n. The tracks are bidirectional, and we have to reach station dest from station src. Thes source and destination stations of the i-th railroad is given in the array 'roads' where roads[i] is of the format {station1, station2}. From the j-th station, a train leaves for all stations that are connected with the station at the multiples of time kj and each train takes tj amount of time to reach the destination. The values are given in an array 'departure' where each element is of ...

Read More
Showing 2681–2690 of 3,768 articles
« Prev 1 267 268 269 270 271 377 Next »
Advertisements