Arnab Chakraborty has Published 4293 Articles

Program to find sum of the deepest nodes in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 11:36:28

114 Views

Suppose we have a binary tree; we have to find the sum of values of its deepest leaves. So if the tree is like −Then the output will be 11.To solve this, we will follow these steps −Define a map m, and maxDepthDefine a recursive method solve(), this will take ... Read More

Program to find sum of the right leaves of a binary tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 11:33:29

194 Views

Suppose we have a binary tree we have to find the sum of all right leaves in a given binary tree.So, if the input is likethen the output will be 17, as there are two right leaves in the binary tree, with values 7 and 10 respectively.To solve this, we ... Read More

Program to check we can find four elements whose sum is same as k or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 11:31:22

126 Views

Suppose we have a list of numbers called nums and a value k, we have to check whether there are four unique elements in the list that add up to k.So, if the input is like nums = [11, 4, 6, 10, 5, 1] k = 25, then the output ... Read More

Program to solve partially filled Sudoku Grid in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 11:26:07

323 Views

Suppose we have a partially filled Sudoku grid and we have to solve this. We know that Sudoku is a 9 × 9 number grid, and the whole grid are also divided into 3 × 3 boxes There are some rules to solve the Sudoku.We have to use digits 1 ... Read More

Program to check whether one tree is subtree of other or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 11:21:36

375 Views

Suppose we have two binary trees. We have to check whether second tree is a subtree of first one or not.So, if the input is likethen the output will be True.To solve this, we will follow these steps −Define a function solve() . This will take root, targetif root is ... Read More

Program to find maximum sum of the subsequence, where difference of two values is same as their position difference in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 11:19:19

193 Views

Suppose we have a list of numbers called nums, we select a subsequence of strictly increasing values, where the differences of each two numbers is the same as the differences of their two indices. So we have to find the maximum sum of such a subsequence.So, if the input is ... Read More

Program to check whether a string is subsequence of other in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 11:17:35

2K+ Views

Suppose we have two strings S and T. We have to check whether S is subsequence of T or not.So, if the input is like S = "abc", T = "adbrcyxd", then the output will be TrueTo solve this, we will follow these steps −if s is same as t, ... Read More

Program to check sublist sum is strictly greater than the total sum of given list Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 11:15:54

291 Views

Suppose we have a list of numbers called nums, we have to check whether there is a sublist such that its sum is strictly greater than the total sum of the list.So, if the input is like nums = [1, −2, 3, 4], then the output will be True, as ... Read More

Program to multiply two strings and return result as string in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 11:13:42

1K+ Views

Suppose we have two numbers as string. We have to multiply them and return the result also in string. So if the numbers are “28” and “25”, then the result will be “700”To solve this, we will follow these steps −Taking two arguments x and y it indicates x divides ... Read More

Program to check maximum sum of all stacks after popping some elements from them in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 11:11:52

299 Views

Suppose we have a list of stacks, we can take any stack or stacks and pop any number of elements from it. We have to find the maximum sum that can be achieved such that all stacks have the same sum value.So, if the input is like stacks = [[3, ... Read More

Advertisements