Arnab Chakraborty has Published 4452 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

124 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

100 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

574 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 longest substring with even vowel counts in Python

Arnab Chakraborty

Arnab Chakraborty

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

333 Views

Suppose we have a string s (lowercase), we have to find the length of the longest substring where each vowel occurs even number of times.So, if the input is like s = "anewcoffeepot", then the output will be 10, as the substring "wcoffeepot" has two vowels "o" and "e", both ... Read More

Program to find length of longest palindromic substring after single rotation in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Dec-2020 12:34:46

143 Views

Suppose we have a string s, which we can rotate at any point exactly once. We have to find the length of the longest palindromic substring we can get by doing this operation.So, if the input is like s = "elklev", then the output will be 7, as we can ... Read More

Program to find longest prefix that is also a suffix in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Dec-2020 12:33:08

385 Views

Suppose we have a string s, we have to find the longest prefix of s, which is also a suffix (excluding itself). If there is no such prefix, then simply return blank string.So, if the input is like "madam", then the output will be "m", it has 4 prefixes excluding ... 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

830 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 length of longest increasing path in a given matrix in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 10:45:43

94 Views

Suppose we have a 2D matrix, we have to find the length of the longest strictly increasing path. To traverse the path we can move up, down, left, or right nor diagonally.So, if the input is like246157339then the output will be 6, as The longest path is [1, 2, 4, ... Read More

Program to find length of longest palindromic subsequence in Python

Arnab Chakraborty

Arnab Chakraborty

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

660 Views

Suppose we have a lowercase string s; we have to find the length of the longest palindromic subsequence in s.So, if the input is like s = "aolpeuvekyl", then the output will be 5, as the palindrome is "level".To solve this, we will follow these steps −n := size of ... 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

130 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

Advertisements