Arnab Chakraborty has Published 4452 Articles

Program to check given push pop sequences are proper or not in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 04:58:16

179 Views

Suppose we have a list of numbers called pushes, and another list of numbers called pops, we have to check whether this is a valid sequence of stack push and pop actions or not.So, if the input is like pushes = [1, 2, 5, 7, 9] pops = [2, 1, ... Read More

Program to find number of square submatrices with 1 in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 04:56:43

92 Views

Suppose we have a 2D binary matrix, we have to find the total number of square submatrices with all 1 s are there.So, if the input is like11101110111000001011then the output will be 17 as there are 12 (1 x 1) squares, 4 (2 x 2) squares and 1 (3 x ... Read More

Program to find final states of rockets after collision in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 04:55:07

108 Views

Suppose we have a list of numbers called nums and that is representing rocket's size and direction. Positive integer indicates right, and negative number represents left. And the absolute value of the number represents the rocket's size. Now when two rockets collide, the smaller one will be destroyed and the ... Read More

Program to find minimum space plane required for skydivers in k days in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 04:53:37

71 Views

Suppose we have a list of numbers called nums where each value represents a group of people looking to skydive together. And we have another value k representing how many days they can apply for skydiving. We have to find the minimum capacity of the plane we need to be ... Read More

Program to find shortest cycle length holding target in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 04:50:46

311 Views

Suppose we have adjacency list of a directed graph, where each list at index i is represented connected nodes from node i. We also have a target value. We have to find the length of a shortest cycle that contains the target. If there is no solution return -1.So, if ... Read More

Program to find total cost for completing all shipments in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 04:47:52

226 Views

Suppose we have a list of lists called ports, where ports[i] represents the list of ports that port i is connected to. We also have another list of lists called shipments where each list of the sequence [i, j] which denotes there is a shipment request from port i to ... Read More

Program to convert a string to zigzag string of line count k in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 08:34:06

274 Views

Suppose we have a string s and another value k, We have to find a new string by taking each character from s and starting diagonally from top left to bottom right until reaching the kth line, then go up to top right, and so on.So, if the input is ... Read More

Program to find length of longest alternating path of a binary tree in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 08:30:08

193 Views

Suppose we have a binary tree, we have to find the longest path that alternates between left and right child and going down.So, if the input is likethen the output will be 5 as the alternating path is [2, 4, 5, 7, 8].To solve this, we will follow these steps:if ... Read More

Program to find length of longest word that can be formed from given letters in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 08:27:28

228 Views

Suppose we have a list of words and a string called letters, we have to find the size of the longest word that can be made by rearranging the given letters. In the letters there may be asterisk character (*) it can match any character. And it is not necessary ... Read More

Program to count number of word concatenations are there in the list in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Nov-2020 08:25:59

116 Views

Suppose we have a list of strings; we have to find the number of words that are concatenations of other words also in the list. We can reuse words when concatenating and concatenate any number of times.So, if the input is like words = ["hello", "world", "helloworld", "famous", "worldfamous", "programming"], ... Read More

Advertisements