Arnab Chakraborty has Published 3734 Articles

Program to find max values of sublists of size k in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Dec-2020 12:43:55

231 Views

Suppose we have a list nums and another value k, we have to find the maximum values of each sublist of size k.So, if the input is like nums = [12, 7, 3, 9, 10, 9] k = 3, then the output will be [12, 9, 10, 10]To solve this, ... Read More

Program to find length of longest sublist whose sum is 0 in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Dec-2020 12:41:36

176 Views

Suppose we have a list with only two values 1 and −1. We have to find the length of the longest sublist whose sum is 0.So, if the input is like nums = [1, 1, −1, 1, 1, −1, 1, −1, 1, −1], then the output will be 8, as ... Read More

Program to find length of longest substring which contains k distinct characters in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Dec-2020 12:39:26

804 Views

Suppose we have a number k and another string s, we have to find the size of the longest substring that contains at most k distinct characters.So, if the input is like k = 3 s = "kolkata", then the output will be 4, as there are two longest substrings ... Read More

Program to find length of the longest path in a DAG without repeated nodes in Python

Arnab Chakraborty

Arnab Chakraborty

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

1K+ Views

Suppose we have one directed acyclic graph represented by the adjacency list. We have to find the longest path in the graph without node repetition.So, if the input is likethen the output will be 4, as the path is 0 -> 1 -> 3 -> 4 -> 2 with length ... Read More

Program to find length of longest path with even sum in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 10:39:35

232 Views

Suppose we have a binary tree. we have to find the length of the longest path whose sum is an even number.So, if the input is like image, then the output will be 5, as the path is like [5, 2, 4, 8, 5], sum = 24(even).To solve this, we ... Read More

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

727 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

397 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 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

430 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

226 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

187 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

Advertisements