Arnab Chakraborty has Published 3734 Articles

Program to fix a erroneous binary tree using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-May-2021 13:27:08

272 Views

Suppose, we are given a binary tree that has a problem; one of the node's right child pointer points to another node at the same level in the binary tree erroneously. So, to fix this problem, we have to find out the node that has this error and delete that ... Read More

Program to change the root of a binary tree using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-May-2021 13:24:48

967 Views

Suppose, we are given a binary tree and a node that is situated at the leaf of the binary tree.We have to make the leaf node the root node of the binary tree. We can do it in the following way −If a node has a left child, it becomes ... Read More

Program to count number of square submatrices with all ones using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-May-2021 13:00:15

241 Views

Suppose we have m x n binary matrix, we have to find how many square submatrices have all ones.So, if the input is like.011111110111then the output will be 15, as there are 10 squares of side 1. 4 squares of side 2 and 1 square of side 3. Then total ... Read More

Program to count submatrices with all ones using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-May-2021 12:59:14

691 Views

Suppose we have m x n binary matrix, we have to find how many submatrices have all ones.So, if the input is like101011011then the output will be 13 as there are 6 (1x1) matrices, 3 (2, 1) matrices, 2 (1x2) matrices, 1 (3x1) matrix and 1 (4x4) matrix.To solve this, ... Read More

Program to find range sum of sorted subarray sums using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-May-2021 12:58:22

441 Views

Suppose we have an array nums with n positive elements. If we compute the sum of all non-empty contiguous subarrays of nums and then sort them in non-decreasing fashion, by creating a new array of n*(n+1)/2 numbers. We have to find the sum of the numbers from index left to ... Read More

Program to find minimum difference between largest and smallest value in three moves using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-May-2021 12:57:41

681 Views

Suppose we have an array called nums. We can change one element from this array to any value in one move. We have to find the minimum difference between the largest and smallest value of nums after preforming at most 3 moves.So, if the input is like nums = [3, ... Read More

Program to find path with maximum probability using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-May-2021 12:56:07

567 Views

Suppose we have an undirected weighted graph with n nodes (nodes are numbered from 0 onwards), This graph is given as input using edge list, for each edge e, it has a probability of success of traversing that edge probability[e]. We also have start and end nodes, we have to ... Read More

Program to find number of nodes in the sub-tree with the same label using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-May-2021 12:54:53

470 Views

Suppose we have a rooted general tree with n nodes, whose nodes are numbered from 0 to n-1. Each node has a label with lowercase English letter. The labels are given as input in labels array, where lables[i] contains label for ith node. The tree is represented by edge list ... Read More

Program to find number of good ways to split a string using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-May-2021 12:51:55

401 Views

Suppose we have a string s. Now a split is said to be a good split when we can split s into 2 non-empty strings p and q where its concatenation is equal to s and the number of distinct letters in p and q are the equal. We have ... Read More

Program to add two polynomials given as linked lists using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-May-2021 14:04:57

3K+ Views

Suppose, we are given two polynomials and we have to find out the addition of the two polynomials. The polynomials have to be represented as linked lists; the terms of the polynomials will be represented as a linked list node. Each linked list node will contain the coefficient value, power ... Read More

Advertisements