Arnab Chakraborty has Published 4452 Articles

Program to find length of longest common subsequence of three strings in Python

Arnab Chakraborty

Arnab Chakraborty

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

571 Views

Suppose we have three strings s1, s2, and s3, we have to find the length of their longest common subsequence.So, if the input is like s1 = "ababchemxde" s2 = "pyakcimde" s3 = "oauctime", then the output will be 4, as the longest common subsequence is "acme".To solve this, we ... Read More

Program to find length of longest arithmetic subsequence of a given list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 10:34:52

311 Views

Suppose we have a list of numbers called nums, we have to find the length of the longest arithmetic subsequence. As we know a sequence S[i] is an arithmetic sequence when S[i+1] - S[i] have the same value for every i in range (0 ≤ i < Size of S ... Read More

Program to find length of longest alternating subsequence from a given list in Python

Arnab Chakraborty

Arnab Chakraborty

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

318 Views

Suppose we have a list of numbers called nums, we have to find the size of the longest subsequence where the difference between two consecutive numbers alternate between positive and negative. And the first difference may be either positive or negative.So, if the input is like nums = [6, 10, ... Read More

Program to check whether we can split list into consecutive increasing sublists or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 10:30:32

278 Views

Suppose we have a list of numbers called nums and that is sorted in non-decreasing order, we have to check whether it can be split into any number of subsequences such that each subsequence has at minimum length of 3 and that is consecutively increasing.So, if the input is like ... Read More

Program to split lists into strictly increasing sublists of size greater than k in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 10:27:46

117 Views

Suppose we have a list of numbers called nums, and another value k, we have to check whether it is possible to split the list into sublists lists such that each sublist has length ≥ k and that is strictly increasing. The list does not need to be split contiguously.So, ... Read More

Program to find largest sum of 3 non-overlapping sublists of same sum in Python

Arnab Chakraborty

Arnab Chakraborty

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

87 Views

Suppose we have a list of numbers called nums and another value k, we have to find the largest sum of three non-overlapping sublists of the given list of size k.So, if the input is like nums = [2, 2, 2, -6, 4, 4, 4, -8, 3, 3, 3] k ... Read More

Program to find maximum sum of two sets where sums are equal in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 10:23:56

80 Views

Suppose we have a list of numbers called nums, now find two sets as their sums are same and maximum, then find sum value.So, if the input is like nums = [2, 5, 4, 6], then the output will be 6, as the sets are [2, 4] and [6].To solve ... Read More

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

103 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

326 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

94 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

Advertisements