Arnab Chakraborty has Published 4452 Articles

Program to find minimum number of vertices to reach all nodes using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-May-2021 13:44:03

370 Views

Suppose we have a directed acyclic graph, with n vertices and nodes are numbered from 0 to n-1, the graph is represented by an edge list, where edges[i] = (u, v) represents a directed edge from node u to node v. We have to find the smallest set of vertices ... Read More

Program to find minimum numbers of function calls to make target array using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-May-2021 13:43:10

224 Views

Suppose we have following function definition:def modify(arr, op, index):    if op == 0:       arr[index] += 1    if op == 1:       for i in range(len(arr)):          arr[i] *=2We have to find minimum number of function calls required to make a ... Read More

Program to find latest group of size M using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-May-2021 13:41:33

120 Views

Suppose we have an array arr this is holding a permutation of numbers from 1 to n. If we have a binary string of size n and initially all its bits set to zero. Now at each step i (Indexing starts from 1 for both the binary string and arr) ... Read More

Program to find out the node in the right in a binary tree using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-May-2021 13:37:28

396 Views

Suppose, we are provided a binary tree. We are also given a pointer to a node (named ‘u’) and we have to find the node situated just right of the provided node. The node situated to the given node's right must stay at the same level and the given node ... Read More

Program to find out the lowest common ancestor of a binary tree using parent pointers using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-May-2021 13:35:22

134 Views

Suppose, we are given a binary tree and also two specific nodes x and y. We have to find out the lowest common ancestor of the two nodes from the binary tree. The lowest common ancestor in a binary tree is the lowest node of which both the nodes x ... Read More

Program to fix a erroneous binary tree using Python

Arnab Chakraborty

Arnab Chakraborty

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

161 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

750 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 find out the lowest common ancestor of a binary tree of given nodes using Python

Arnab Chakraborty

Arnab Chakraborty

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

121 Views

Suppose, we are given a binary tree and are asked to find out the lowest common ancestor of all the nodes in the tree. The lowest common ancestor in a binary tree is the lowest node of which the nodes x1, x2, x3, ...., xn are descendants. A particular node ... Read More

Program to find number of subsequences that satisfy the given sum condition using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-May-2021 13:01:01

496 Views

Suppose we have an array called nums and another value k. We have to find the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is smaller or equal to k. The answers may be very large so return answer mod ... 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

134 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

Advertisements