Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 93 of 377

Find the minimum number of moves needed to move from one cell of matrix to another in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 420 Views

Suppose we have one N X N matrix M, and this is filled with 1, 0, 2, 3, We have to find the minimum numbers of moves required to move from source cell to destination cell. While visiting through blank cells only, we can visit up, down, right and left.Cell with value 1 indicates Source.Cell with value 2 indicates Destination.Cell with value 3 indicates Blank cell.Cell with value 0 indicates Blank Wall.There will be only one source and only one destination cells. There may be more than one path to reach destination from source cell. Now, each move in matrix ...

Read More

Find the minimum number of preprocess moves required to make two strings equal in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 325 Views

Suppose we have two strings P and Q of same lengths with only lower case letters, we have to count the minimum number of pre-processing moves on string P are needed to make it equal to string Q after applying below operations −Select any index i and swap characters pi and qi.Select any index i and swap characters pi and pn – i – 1.Select any index i and swap characters qi and qn – i – 1.Note − The value of i in range (0 ≤ i < n)In one move we can change a character in P with any ...

Read More

Find the minimum number of rectangles left after inserting one into another in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 279 Views

Suppose we have width and height of N different rectangles; we have to find the minimum number of rectangles left after inserting one into another. So, if W1 and W2 be the width of rectangles R1 and R2 respectively. And H1 and H2 be the height of R1 and R2 respectively, then if W1 < W2 and H1 < H2 then rectangle R1 fits inside rectangle R2. Thus, the smallest one can fit into second smallest, then that fits into the next and so on.So, if the input is like {{ 30, 45 }, { 15, 15 }, { 45, ...

Read More

Find the minimum positive integer such that it is divisible by A and sum of its digits is equal to B in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 328 Views

Suppose we have two numbers A and B, we have to find the minimum positive number M so that M is divisible by A and the sum of the digits of M is same as B. So, if there is no such result, then return -1.So, if the input is like A = 50, B = 2, then the output will be 200 as this is divisible by 50 and sum of its digit = 2 + 0 + 0 = 2.To solve this, we will follow these steps −Define one element type container, that contains two numbers a and ...

Read More

Find the minimum sum of distance to A and B from any integer point in a ring of size N in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 183 Views

Suppose we have a ring, which is made of few numbers from 1 to N. We also have tow numbers A and B. Now, we can stand at any place (say x) and perform the count operation with respect of the total sum of the distance (say Z = distance from X to A + distance from X to B). We have to select X such that Z is minimized. At the end return the value of Z. We have to keep in mind that X will not be same as A and B.So, if the input is like N ...

Read More

Find the minimum time after which one can exchange notes in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 177 Views

Suppose there are n number of cashiers exchanging the money, at the moment, the i-th cashier had ki number of people in front of him/her. Now, the j-th person in the line to i-th cashier had m[i, j] notes. We have to find how early can one exchange his/her notes. We have to keep in mind that the cashier spent 5 seconds to scan a single note.After completing scanning of every note for the customer, he/she took 15 seconds to exchange the notes.So, if the input is like Input : n = 6, k = [12, 12, 12, 12, 12, ...

Read More

Find the missing value from the given equation a + b = c in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 658 Views

Suppose we have one equation in this form: a + b = c, now any one of the terms of a, b or c is missing. We have to find the missing one.So, if the input is like ? + 4 = 9, then the output will be 5To solve this, we will follow these steps −delete all blank spaces from the string and change (+ and = to comma ', ')elements := a list of elements by splitting the string separated by commaidx := 0for i in range 0 to size of elements, doif elements[i] is not numeric, thenidx ...

Read More

Find the number of consecutive zero at the end after multiplying n numbers in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 278 Views

Suppose we have an array with n numbers, we have to return the number of consecutive zero’s at the end after multiplying all the n numbers.So, if the input is like [200, 20, 5, 30, 40, 14], then the output will be 6 as 200 * 20 * 5 * 30 * 40 * 14 = 336000000, there are six 0s at the end.To solve this, we will follow these steps −Define a function count_fact_two() . This will take ncount := 0while n mod 2 is 0, docount := count + 1n := n / 2 (only the quotient as ...

Read More

Find the number of distinct pairs of vertices which have a distance of exactly k in a tree in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 317 Views

Suppose we have an integer k and also have a tree with n nodes, we have to count the number of distinct pairs of vertices which have a exact k distance.So, if the input is like k = 2then the output will be 4To solve this, we will follow these steps −N := 5005graph := adjacency list of size Nvertex_count := a 2d matrix of size 505 x 5005res := 0Define a function insert_edge() . This will take x, yinsert y at the end of graph[x]insert x at the end of graph[y]Define a function dfs() . This will take v, ...

Read More

Find the number of rectangles of size 2x1 which can be placed inside a rectangle of size n x m in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 245 Views

Suppose we have two values n and m; we have to find the number of rectangles of size 2x1 that can be set inside a rectangle of size n x m. There are few conditions, that we have to consider −Any two small rectangles cannot overlap.Every small rectangle lies completely inside the bigger one. It is permitted to touch the edges of the bigger rectangle.So, if the input is liken = 3, m = 3, then the output will be 4To solve this, we will follow these steps −if n mod 2 is same as 0, thenreturn(n / 2) * ...

Read More
Showing 921–930 of 3,768 articles
« Prev 1 91 92 93 94 95 377 Next »
Advertisements