Arnab Chakraborty has Published 4452 Articles

Program to find maximum value we can get in knapsack problem by taking multiple copies in Python

Arnab Chakraborty

Arnab Chakraborty

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

485 Views

Suppose we have two lists of same length they are called weights and values, and we also have another value capacity. Here weights[i] and values[i] represent the weight and value of the ith item. If we can take at most capacity weights, and that we can take any number of ... Read More

Program to count number of perfect squares are added up to form a number in C++

Arnab Chakraborty

Arnab Chakraborty

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

73 Views

Suppose we have a positive number n, we have to find the least number of perfect square numbers whose sum is same as n. So if the number is 10, then the output is 2, as the numbers are 10 = 9 + 1.To solve this, we will follow these ... Read More

Program to count number of ways we can distribute coins to workers in Python

Arnab Chakraborty

Arnab Chakraborty

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

258 Views

Suppose we have two lists of positive numbers called coins and salaries. Here coins[i] indicates the value for coin i and salaries[j] indicates the least amount of salary required to pay for worker j. Now suppose we have one coin per type and we must give each worker exactly one ... Read More

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

119 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

879 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

180 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

365 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

92 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

159 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

198 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

Advertisements