Arnab Chakraborty has Published 4452 Articles

Program to find three unique elements from list whose sum is closest to k Python

Arnab Chakraborty

Arnab Chakraborty

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

177 Views

Suppose we have a list of numbers called nums and another value k, we have to find three unique entries in nums (a, b, c) such that |a + b + c − k| is minimized and return the absolute difference.So, if the input is like nums = [2, 5, ... Read More

Program to check number of triplets from an array whose sum is less than target or not Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Oct-2020 11:40:48

144 Views

Suppose we have a list of numbers called nums and another value target, we have to find the number of triples (i < j < k) that exist such that nums[i] + nums[j] + nums[k] < target.So, if the input is like nums = [−2, 6, 4, 3, 8], target ... Read More

Program to check we can find three unique elements ose sum is same as k or not Python

Arnab Chakraborty

Arnab Chakraborty

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

58 Views

Suppose we have a list of numbers called nums and another value k, we have to check whether we can find three unique elements in the list whose sum is k.So, if the input is like nums = [11, 4, 6, 10, 5, 1] k = 20, then the output ... Read More

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

Arnab Chakraborty

Arnab Chakraborty

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

75 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

106 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

70 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

235 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

283 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

106 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

1K+ 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

Advertisements