Arnab Chakraborty has Published 4293 Articles

Program to find largest binary search subtree from a given tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 10:19:16

161 Views

Suppose we have a binary tree, we have to find the largest subtree (with maximum number of nodes) as binary search tree.So, if the input is likethen the output will beTo solve this, we will follow these steps −max_size := [0]max_node := [null]Define a function traverse() . This will take ... Read More

Program to find number of ways we can reach from top left point to bottom right point in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 10:16:40

392 Views

Suppose we have one N x M binary matrix. Where 0 means empty cell and 1 means blocked cell. Now starting from the top left corner, we have to find the number of ways to reach the bottom right corner. If the answer is very large, mod it by 10^9 ... Read More

Program to check whether we can partition a list with k-partitions of equal sum in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 10:12:50

172 Views

Suppose we have a list of numbers called nums and another value k, we have to check whether it is possible to partition nums into k different subsets where the sum of each subset are same.So, if the input is like nums = [4, 2, 6, 5, 1, 6, 3] ... Read More

Program to count number of sublists with exactly k unique elements in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 10:08:47

193 Views

Suppose we have a list of numbers called nums and another value k, we have to find the number of sublists required that there are exactly k unique numbers in the sublist.So, if the input is like nums = [2, 2, 3, 4] k = 2, then the output will ... Read More

Program to find sum of k non-overlapping sublists whose sum is maximum in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 10:07:09

216 Views

Suppose we have a list of numbers called nums, and another value k, we have to find the k non-overlapping, non-empty sublists such that the sum of their sums is maximum. We can consider k is less than or equal to the size of nums.So, if the input is like ... Read More

Program to find lexicographically smallest subsequence of size k in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 10:04:26

334 Views

Suppose we have a list of numbers called nums and another value k, we have to find the lexicographically smallest subsequence of size k.So, if the input is like nums = [2, 3, 1, 10, 3, 4] k = 3, then the output will be [1, 3, 4]To solve this, ... Read More

Program to justify a set of words by converting them into same length lines in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 10:00:33

102 Views

Suppose we have an list of words and a width k, we have to arrange the text such that each line has exactly k number of characters and the text is fully justified. Here we shall pack our words as many words as we can insert in each line. And ... Read More

Program to find minimum sum of difficulties to complete jobs over k days in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 09:55:42

192 Views

Suppose we have a list of numbers called jobs and another value k. Now we want to finish all jobs in k different days. The jobs must be performed in the given order and in each day we have to complete one task. The difficulty of job i is stored ... Read More

Program to get maximum profit by scheduling jobs in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 09:53:00

830 Views

Suppose we have a list of intervals where each interval contains three values [start, end, profit]. We can perform only one task at a time, we have to find the most amount of profit we can get.So, if the input is like intervals = [[1, 2, 100], [3, 5, 40], ... Read More

Program to find all possible IP address after restoration in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 09:49:18

347 Views

Suppose we have a string with only digits, we have to restore it by forming all possible valid IP address combinations. We know that a valid IP address consists of exactly four integers (each integer is in range 0 to 255) separated by single period symbol.So, if the input is ... Read More

Advertisements