Arnab Chakraborty has Published 4293 Articles

Program to check whether we can pick up and drop every passenger in given list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 12:23:47

355 Views

Suppose we have a matrix called requested_trips where each row containing [start_x, end_x, num_passengers], and we also have a capacity value. Now each requested trip asks to pick up num_passengers passenger at start_x and drop them off at end_x. We also have a car with the capacity that is given, ... Read More

Program to find the sum of the lengths of two nonoverlapping sublists whose sum is given in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 12:21:48

146 Views

Suppose we have a list of numbers called nums and another value k, we have to find two nonoverlapping sublists in nums whose sum is k, and we have to find the sum of their lengths. When there are more than two possible sublists, we have to find the sum ... Read More

Program to check two trees are exactly same based on their structure and values in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 12:19:58

159 Views

Suppose we have two binary trees, we have to check whether they are exactly same in terms of their structures and values or not. We can say them as twin trees.So, if the input is likethen the output will be True for the first pair, false for the second pair ... Read More

Program to find possible number of palindromes we can make by trimming string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 12:18:07

215 Views

Suppose we have a string s, we have to find the number of ways we can obtain a palindrome by trimming the left and right sides of s.So, if the input is like s = "momo", then the output will be 6, as You can get ["mom", "omo", "o", "o", ... Read More

Program to count number of valid triangle triplets in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 12:16:17

861 Views

Suppose we have an array of numbers, we have to find the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle. So if the input is like [2, 2, 3, 4], then the result will be 3 as ... Read More

Program to traverse binary tree using list of directions in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 12:14:42

281 Views

Suppose we have a binary tree and a list of strings moves consisting of "R"(Right), "L"(Left) and "U"(Up). Starting from root, we have to traverse the tree by performing each move in moves where: "R" indicates traverse to the right child. "L" indicates traverse to the left child. "U" indicates ... Read More

Program to find sum of all elements of a tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 12:12:43

934 Views

Suppose we have a binary tree containing some values, we have to find the sum of all values in the tree.So, if the input is likethen the output will be 14To solve this, we will follow these steps −Define a function recurse() . This will take nodeval := value of ... Read More

Program to pruning a given binary tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 12:10:20

379 Views

Suppose we have a binary tree, where every node's value is either a 0 or a 1. We have to find the same tree where every subtree not containing a 1 has been deleted. So if the tree is like −To solve this, we will follow these steps −Define a ... Read More

Program to find minimum distance that needs to be covered to meet all person in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 12:08:16

238 Views

Suppose we have a 2D matrix there are few values like below −0 represents an empty cell.1 represents a wall.2 represents a person.Here a person can walk any of these four directions (up, down, left and right). We have to find a cell that is not wall such that it ... Read More

Program to find minimum number of cells it will take to reach bottom right corner in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 12:04:30

225 Views

Suppose we have a 2D grid representing a maze where 0 is for empty space, and 1 is the wall. We will start at grid[0, 0], we have to find the minimum number of squares it would take to get to bottom right corner of the grid. If we cannot ... Read More

Advertisements