Arnab Chakraborty has Published 4293 Articles

Program to count how many ways we can divide the tree into two trees in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 07:31:58

204 Views

Suppose we have a binary tree containing values 0, 1 and 2. The root has at least one 0 node and one 1 node. Now suppose there is an operation where we delete an edge in the tree and the tree becomes two different trees. We have to find the ... Read More

Program to find leaf and non-leaf nodes of a binary tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 07:27:36

1K+ Views

Suppose we have a binary tree, we have to find a list of two numbers where the first number is the count of leaves in the tree and the second number is the count of non-leaf nodes.So, if the input is likethen the output will be (3, 2), as there ... Read More

Program to check whether inorder sequence of a tree is palindrome or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 07:25:11

268 Views

Suppose we have a binary tree where each node contains a digit from 0-9, we have to check whether its in-order traversal is palindrome or not.So, if the input is likethen the output will be True, as its inorder traversal is [2, 6, 10, 6, 2].To solve this, we will ... Read More

Program to check given string is anagram of palindromic or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 07:20:37

691 Views

Suppose we have a string s, we have to check whether any permutation of s is a palindrome or not.So, if the input is like s = "admma", then the output will be True, as we can rearrange "admma" to "madam" which is a palindrome.To solve this, we will follow ... Read More

Program to check linked list items are forming palindrome or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 07:19:16

157 Views

Suppose we have a linked list. We have to check whether the list elements are forming a palindrome or not. So if the list element is like [5, 4, 3, 4, 5], then this is a palindrome, but a list like [5, 4, 3, 2, 1] is not a palindrome.To ... Read More

Program to swap nodes of a linked list pair wise in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 07:17:01

245 Views

Suppose we have a linked list. We have to swap every two adjacent nodes (pair) and return its head. Here the constraint is that, we cannot modify the value of the nodes, only the node itself can be changed. So if the list is like [1, 2, 3, 4], then ... Read More

Program to count maximum number of distinct pairs whose differences are larger than target in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 07:14:13

308 Views

Suppose we have a list of numbers called nums and another value target. We have to find the maximum number of pairs where for each pair i < j, i and j are not in any other pair, and |nums[i] - nums[j]| >= target.So, if the input is like nums ... Read More

Program to fill with color using floodfill operation in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 07:12:10

279 Views

Suppose we have a 2D grid, containing colors as strings "r", "g", and "b". We have to perform floodfill operation at row r, column c with the color target. As we know the Floodfill operation should replace all elements that are both connected to grid[r, c] (up/right/down/left) and have the ... Read More

Program to pack same consecutive elements into sublist in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Oct-2020 07:07:54

545 Views

Suppose we have a list of numbers nums, we will pack consecutive elements of the same value into sublists. We have to keep in mind that there is only one occurrence in the list it should still be in its own sublist.So, if the input is like nums = [5, ... Read More

Program to find one minimum possible interval to insert into an interval list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Oct-2020 16:19:58

163 Views

Suppose we have a 2D list of numbers called intervals where each row represents [start, end] (inclusive) interval. For an interval [a, b] (a < b), its size is (b - a). We must add one interval to the given list such that, after merging all the intervals, we get ... Read More

Advertisements