Arnab Chakraborty has Published 4293 Articles

Program to find length of longest increasing subsequence in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 13:10:29

580 Views

Suppose we have a list of numbers. We have to find the length of longest increasing subsequence. So if the input is like [6, 1, 7, 2, 8, 3, 4, 5], then the output will be 5, as the longest increasing subsequence is [2, 3, 4, 5, 6].To solve this, ... Read More

Program to find length of longest common substring in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 12:15:42

2K+ Views

Suppose we have two lowercase strings X and Y, we have to find the length of their longest common substring.So, if the input is like X = "helloworld", Y = "worldbook", then the output will be 5, as "world" is the longest common substring and its length is 5.To solve ... Read More

Program to find length of longest common subsequence in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 12:05:58

247 Views

Suppose we have two strings text1 and text2, we have to find the length of their longest common subsequence. As we know a subsequence of a string is a new string generated from the original string with some characters deleted without changing the relative order of the remaining characters. (So ... Read More

Program to find length of longest bitonic subsequence in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 12:00:43

223 Views

Suppose we have a list of numbers. We have to find length of longest bitonic subsequence. As we knot a sequence is said to be bitonic if it's strictly increasing and then strictly decreasing. A strictly increasing sequence is bitonic. Or a strictly decreasing sequence is bitonic also.So, if the ... Read More

Program to partition color list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 11:37:39

595 Views

Suppose we have a a list of color strings, these may contain "red", "green" and "blue", we have to partition the list so that the red come before green, and green come before blue.So, if the input is like colors = ["blue", "green", "blue", "red", "red"], then the output will ... Read More

Program to check whether list can be split into sublists of k increasing elements in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 11:31:20

144 Views

Suppose we have a list of numbers called nums, and another number k, we have to check whether the list can be split into lists where each list contains k values and the values are consecutively increasing.So, if the input is like nums = [4, 3, 2, 4, 5, 6], ... Read More

Program to create linked list to binary search tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 11:24:02

1K+ Views

Suppose we have a sorted linked list node of size n, we have to create a binary search tree by Taking the value of the k = floor of (n / 2) the smallest setting it as the root. Then recursively constructing the left subtree using the linked list left ... Read More

Program to find tree level that has minimum sum in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 11:18:23

288 Views

Suppose we have a binary tree, the level of its root is 1, the level of its children is 2, and so on.We have to find the smallest level X such that the sum of all the values of nodes at level X is minimum. So if the tree is ... Read More

Program to perform level order traversal of binary tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 11:10:22

261 Views

Suppose we have a binary tree. We have to traverse this tree using level order traversal fashion. So if the tree is likeThe traversal sequence will be like: [1, 2, 3, 5, 4]To solve this, we will follow these steps −define queue que to store nodesinsert root into the que.while ... Read More

Program to convert level order binary tree traversal to linked list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Oct-2020 11:02:09

417 Views

Suppose we have a binary search tree, we have to convert it to a singly linked list using levelorder traversal.So, if the input is likethen the output will be [5, 4, 10, 2, 7, 15, ]To solve this, we will follow these steps −head := a new linked list nodecurrNode ... Read More

Advertisements