Arnab Chakraborty has Published 4452 Articles

Program to find distance of shortest bridge between islands in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 08:50:57

378 Views

Suppose we have a binary matrix, where 0 represents water and 1 represents the land. An island is a group of connecting 1s in 4 directions. Islands are either surrounded by 0s (water) or by the edges. We have to find the length of shortest bridge that connects two islands.So, ... Read More

Program to evaluate s-expression as string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 08:47:31

411 Views

Suppose we have a string s as S-expression. We have to evaluate that S-expression and return result as integer. As we know that the s-expression is an expression which is either one number, or a recursive expression wrapped in parentheses like (+ (- 3 2) (* 3 3)), which indicates ... Read More

Program to check we can replace characters to make a string to another string or not in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 08:45:22

115 Views

Suppose we have two lowercase strings s and t. Now consider an operation where we replace all occurrences of a character in s with another character. If we can perform this operation any number of times, we have to check whether s can be converted to t or not.So, if ... Read More

Program to find number of operations required to remove palindromic sublists in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 08:43:21

179 Views

Suppose we have a list of numbers called nums. Now let us consider an operation where we delete some sublist which is a palindrome. We have to find the minimum number of operations required such that the list is empty.So, if the input is like nums = [6, 2, 4, ... Read More

Program to check regular expression pattern is matching with string or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 08:41:32

424 Views

Suppose we have a string s and a regular expression pattern. We have to check whether the given pattern matches with given string or not. In the regular expression, there are few rules −. (period) which matches any single character* (asterisk) which matches zero or more of the preceding element.So, ... Read More

Program to count number of square submatix of 1s in the given matrix in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 08:38:59

102 Views

Suppose we have a 2d binary matrix, we have to find the total number of submatrices with all 1 s.So, if the input is like110110001then the output will be 10, as there five 1 x 1 matrix, two 2 x 1 matrix. two 1 x 2 matrices. And one 2 ... Read More

Program to count number of unique paths that includes given edges in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 08:36:38

267 Views

Suppose we have a list of edges in the form (u, v) and these are representing a tree. For each edge we have to find the total number of unique paths that includes said edge, in the same order as given in the input.So, if the input is like edges ... Read More

Program to count number of points that lie on a line in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 08:35:06

522 Views

Suppose we have a list of coordinates. Each coordinate has two values x and y, representing a point on the Cartesian plane. Now find the maximum number of points that lie on some line.So, if the input is like coordinates = [[6, 2], [8, 3], [10, 4], [1, 1], [2, ... Read More

Program to count number of ways we can place nonoverlapping edges to connect all nodes in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 08:32:18

69 Views

Suppose we have a number n that is representing the number of nodes that are placed circularly. We have to find the number of ways we can place n / 2 edges such that every node is connected by an edge, and that edges does not intersect with each other. ... Read More

Program to find minimum cost to pick up gold in given two locations in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 08:29:11

105 Views

Suppose we have a 2d matrix and some other values like row, col, erow0, ecol0, erow1, and ecol1. If our current position is matrix [row, col] and we want to pick up gold that is at matrix [erow0, ecol0] and matrix [erow1, ecol1]. We can go up, down, left, and ... Read More

Advertisements