Arnab Chakraborty has Published 3734 Articles

Program to find minimum swaps to arrange a binary grid using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-May-2021 13:52:45

368 Views

Suppose we have a n x n binary matrix. We can perform an operation on it like, at one step we select two adjacent rows and swap them. We have to count number of minimum swaps required, so that all nodes above the major diagonal of the matrix is 0. ... Read More

Program to check whether we can convert string in K moves or not using Python

Arnab Chakraborty

Arnab Chakraborty

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

254 Views

Suppose we have two strings s and t, we have to check whether s can be converted to t in k moves or less. In ith move you can do these operations.Select any index j (starting from 1) in s, such that 1

Program to find Kth bit in n-th binary string using Python

Arnab Chakraborty

Arnab Chakraborty

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

448 Views

Suppose we have two positive values n and k, now we can make a binary string S_n by using following rules −S_1 = 0S_i = S_i-1 concatenate "1" concatenate reverse(invert(S_i-1)) for i > 1Here reverse(x) returns the reversed string x, and invert(x) flips all the bits in x.These are the ... Read More

Program to find maximum number of non-overlapping subarrays with sum equals target using Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-May-2021 13:45:25

238 Views

Suppose we have an array nums and another value called target. Now we have to find the maximum number of non-empty non-overlapping subarrays such that the sum of values in each different subarray is same as target.So, if the input is like nums = [3, 2, 4, 5, 2, 1, ... Read More

Program to find minimum operations to make array equal using Python

Arnab Chakraborty

Arnab Chakraborty

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

310 Views

Suppose we have a value n, consider an array nums with n elements, where arr[i] = (2*i)+1 for all i. Now in one operation, we can choose two indices x and y where 0 =0, doans:= ans + (n-j)q := q - 1j := j + 2return ansLet us see ... Read More

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

535 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

344 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

243 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

561 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

231 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

Advertisements