Arnab Chakraborty has Published 4452 Articles

Program to find length longest prefix sequence of a word array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:43:22

174 Views

Suppose we have a list of words called w, with lowercase strings. We have to find the length of the longest sequence of w where each previous word is the prefix of the next word and the next word has just one new character appended.So, if the input is like ... Read More

Program to find length of longest matrix path length in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:40:59

177 Views

Suppose we have a binary matrix, where 0 indicates empty cell and 1 indicates wall. We can start at any empty cell on first row and want to end up on any empty cell on the last row. We can move left, right, or down, we have to find the ... Read More

Program to find length of longest contiguously strictly increasing sublist after removal in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:37:33

406 Views

Suppose we have a list of numbers called nums, we have to find the maximum length of a contiguous strictly increasing sublist. We are allowed to remove at most single element from the list.So, if the input is like nums = [35, 5, 6, 7, 8, 9, 12, 11, 26], ... Read More

Program to find length of longest consecutively increasing substring in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:34:44

179 Views

Suppose we have a lowercase string s. This contains English letters as well as "?" Symbol. For each "?" we must either remove it or replace it with any lowercase letter. We have to find the length of the longest consecutively increasing substring that starts with letter "a".So, if the ... Read More

Program to find longest consecutive run of 1s in binary form of n in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:29:27

551 Views

Suppose we have a non-negative value n, we have to find the length of the longest consecutive run of 1s in its binary representation.So, if the input is like n = 1469, then the output will be 4, because binary representation of 156 is "10110111101", so there are four consecutive ... Read More

Program to find length of longest arithmetic subsequence with constant difference in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:26:39

140 Views

Suppose we have a list of numbers nums and another value diff, we have to find the length of the longest arithmetic subsequence where the difference between any consecutive numbers in the subsequence is same as diff.So, if the input is like nums = [-1, 1, 4, 7, 2, 10] ... Read More

Program to find length of longest substring with 1s in a binary string after one 0-flip in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:24:25

563 Views

Suppose we have a binary string s. We are allowed to flip at most one "0" to "1", we have to find the length of the longest contiguous substring of 1s.So, if the input is like s = "1010110001", then the output will be 4, as if we flip the ... Read More

Program to find largest size to truncate logs to store them completely in database in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:21:36

89 Views

Suppose we have a list of numbers called logs and another value limit. Each element in logs[i] represents the size of logs generated by the i-th user. And limit represents the total size of logs we can store in our database. We have to find the largest x such that ... Read More

Program to find minimum length of first split of an array with smaller elements than other list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:19:28

146 Views

Suppose we have a list of numbers nums, we want to split the list into two parts part1 and part2 such that every element in part1 is less than or equal to every element in part1. We have to find the smallest length of part1 that is possible (not 0 ... Read More

Program to count number of on lights flipped by n people in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2021 10:17:19

118 Views

Suppose we have a number n, consider there are n toggle switches in a room and there are n people present in that room, they flip switches as follows −Person 1 comes and flips all switches.Person 2 comes and flips switches that are multiples of 2: 2, 4, 6, ...Person ... Read More

Advertisements