Arnab Chakraborty has Published 4452 Articles

Program to find nth term in Look and Say Sequence in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 07:28:45

543 Views

Suppose we have a number n we have to generate nth term in “Look and Say” sequence. This is a sequence whose few terms are like below −111211211111221The string will be read like1 (One)11 (One 1) So read the previous 1, and say “One 1”21 (Two 1) So read the ... Read More

Program to find length of longest substring with character count of at least k in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 07:26:55

149 Views

Suppose we have a string s where each characters are sorted and we also have a number k, we have to find the length of the longest substring such that every character occurs at least k times.So, if the input is like s = "aabccddeeffghij" k = 2, then the ... Read More

Program to find length of longest sublist where difference between min and max smaller than k in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 07:24:34

188 Views

Suppose we have a list of numbers called nums and another value k, we have to find the length of longest sublist where the absolute difference between the largest and smallest element is ≤ k.So, if the input is like nums = [2, 4, 6, 10] k = 4, then ... Read More

Program to find length of longest set of 1s by flipping k bits in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 07:22:23

118 Views

Suppose we have a binary list, so here only 1s and 0s are available and we also have another number k. We can set at most k 0s to 1s, we have to find the length of the longest sublist containing all 1s.So, if the input is like nums = ... Read More

Program to find length of longest strictly increasing then decreasing sublist in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 07:20:36

350 Views

Suppose we have a list of numbers called nums. We have to find the length of the longest sublist such that (minimum length 3) its values are strictly increasing and then decreasing.So, if the input is like nums = [7, 1, 3, 5, 2, 0], then the output will be ... Read More

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

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 07:18:32

151 Views

Suppose we have a list of numbers called nums, we have to find the length of longest subsequence that flips sign on each consecutive number.So, if the input is like nums = [1, 3, -6, 4, -3], then the output will be 4, as we can pick [1, -6, 4, ... Read More

Program to find length of longest interval from a list of intervals in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 07:16:22

368 Views

Suppose we have a list of intervals where each interval is in form [start, end]. We have to find the longest interval that we can make by merging any number of overlapping intervals.So, if the input is like [[1, 6], [4, 9], [5, 6], [11, 14], [16, 20]], then the ... Read More

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

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 07:14:18

270 Views

Suppose we have a list of strictly increasing positive numbers called nums. We have to find the length of the longest subsequence A (of length minimum 3) such that A[i] = A[i - 1] + A[i - 2] for all i > 1.So, if the input is like nums = ... Read More

Program to find longest number of 1s after swapping one pair of bits in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 07:12:39

404 Views

Suppose we have a binary string s. If we can swap at most one pair of characters in the string, we have to find the resulting length of the longest contiguous substring of 1s.So, if the input is like s = "1111011111", then the output will be 9, as we ... Read More

Program to convert a linked list into a binary search tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 07:11:15

415 Views

Suppose we have a singly linked list where elements are arranged in non-decreasing order, we have to convert it to a height balanced binary search tree. So if the list is like [-10, -3, 0, 5, 9], The possible tree will be like −To solve this, we will follow these ... Read More

Advertisements