Arnab Chakraborty has Published 4293 Articles

Program to find top view of a binary tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Dec-2020 05:55:52

342 Views

Suppose we have a binary tree, we have to find the top view of the tree, they will be sorted left−to−right.So, if the input is like image, then the output will be [3, 5, 8, 6, 9], as 3 is above 2 and 5 is above 7 so they are ... Read More

Program to find number of minimum steps required to meet all person at any cell in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Dec-2020 05:53:06

182 Views

Suppose we have a 2D matrix where these values are present: 0 represents an empty cell. 1 represents a wall. 2 represents a person. Now a person can walk any of the four direction of up, down, left, right otherwise stay in one time unit. We have to find a ... Read More

Program to find minimum number of steps required to catch the opponent in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Dec-2020 05:49:05

223 Views

Suppose we have a list of tree edges in the form [u, v], this indicates there is an undirected edge between u and v. And we also have two values x and y. If we are at node x, and our opponent is at node y. In the first round, ... Read More

Program to find minimum number of swaps needed to arrange all pair of socks together in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Dec-2020 05:46:28

186 Views

Suppose we have a list of numbers called row and this is representing socks lying in a row. They are not sorted, but we want to rearrange them so that each pair of socks are side by side like (0, 1), (2, 3), (4, 5), and so on. We have ... Read More

Program to find sum of medians of all odd length sublists in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Dec-2020 05:44:53

276 Views

Suppose we have a list of numbers called nums, we have to find the sum of the medians of every odd−length sublist of the given list.So, if the input is like nums = [2, 4, 6, 3], then the output will be 23, as the odd−length sublists are − [2], ... Read More

Program to Find the Shortest Distance Between Two Points in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Dec-2020 07:04:51

1K+ Views

Suppose we have a list of coordinates where each element is of the form [x, y], representing Euclidean coordinates. We have to find the smallest squared distance (x1 - x2) 2 + (y1 - y2) 2 between any two provided coordinates.So, if the input is like coordinates = {{1, 2}, ... Read More

Program to Find Out the Maximum Final Power of a List in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Dec-2020 07:03:03

235 Views

Suppose, we have a list and the power of a list is defined by the sum of (index + 1) * value_at_index over all indices. Alternatively, we can represent it like this −$$\displaystyle\sum\limits_{i=0}^{n-1} (i+1)\times list[i]$$Now, we have a list nums that has N positive integers. We can select any singular ... Read More

Program to Find Out the Minimum Cost Possible from Weighted Graph in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Dec-2020 07:00:57

782 Views

Suppose we have a 2D list of integers called edges which are a representation of an undirected graph. Every row in the input represents an edge [u, v, w] meaning nodes u and v are connected and the edge has the weight w. The graph consists of n nodes from ... Read More

Program to Find Out the Number of Corrections to be Done to Fix an Equation in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Dec-2020 06:58:19

216 Views

Suppose we have a string s which represents an equation of the form x+y=z. We have to find the minimum number of digits that we need to add into s so the equation becomes true.So, if the input is like s = '2+6=7', then the output will be 2.We can ... Read More

Program to Find Out the Points Achievable in a Contest in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Dec-2020 06:55:53

219 Views

Suppose we are in a programming contest where there are multiple problems but the contest ends when we solve one problem. Now if we have two lists of numbers of the same length called points, and chances. To explain it, here for the ith problem, we have a chances[i] percent ... Read More

Advertisements