Arnab Chakraborty has Published 4293 Articles

Program to find a triplet nums[i] < nums[k] < nums[j] from a list nums in C++

Arnab Chakraborty

Arnab Chakraborty

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

299 Views

Suppose we have a list of numbers called nums, we have to check whether there are triplets (i, j, k) such that i < j < k and nums[i] < nums[k] < nums[j].So, if the input is like nums = [2, 12, 1, 4, 4], then the output will be ... Read More

Program to remove all islands which are completely surrounded by water in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 08:55:56

734 Views

Suppose we have a binary matrix where 1 represents land and 0 represents water. And an island is a group of 1's that are surrounded by 0s (water) or by the edges. We have to find all of the islands that are completely surrounded by water and modify them into ... Read More

Program to find length of shortest supersequence in Python

Arnab Chakraborty

Arnab Chakraborty

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

175 Views

Suppose we have two strings s and t. We have to find the length of the shortest string that has both s and t as subsequences.So, if the input is like s = "pipe" t = "people", then the output will be 7, as one possible supersequence is "pieople".To solve ... Read More

Program to find distance of shortest bridge between islands in Python

Arnab Chakraborty

Arnab Chakraborty

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

454 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

534 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

196 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

267 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

572 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

184 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

355 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

Advertisements