Arnab Chakraborty has Published 4293 Articles

Coin Change in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 11:50:21

5K+ Views

Suppose we have coins of different denominations and a total amount of money amount. We have to define one function to compute the fewest number of coins that we need to make up that amount. When that amount of money cannot be accommodated by any combination of the coins, return ... Read More

Sum Root to Leaf Numbers in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 11:45:08

447 Views

Suppose we have a binary tree containing digits from 0-9 only, here all root-to-leaf path could represent a number.So if the tree is like −This is representing two paths 21 and 23, so the output will be 21 + 23 = 44.To solve this, we will follow these steps −Create ... Read More

Unique Binary Search Trees II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 11:21:10

421 Views

Suppose we have an integer n, we have to generate all structurally unique binary search trees that store values from 1 to n. So if the input is 3, then the trees will be −To solve this, we will follow these steps −Define one recursive function called generate(), this will ... Read More

Missing Number In Arithmetic Progression using C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 11:13:44

336 Views

Suppose we have an array that represents elements of arithmetic progression in order. One element is missing. We have to find the missing element. So if arr = [2, 4, 8, 10, 12, 14], output is 6, as 6 is missing.Using binary search, we can solve this problem. We will ... Read More

N-th Tribonacci Number in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 11:07:03

405 Views

Suppose we have a value n, we have to generate n-th Tribonacci number. The Tribonacci numbers are similar to the Fibonacci numbers, but here we are generating a term by adding three previous terms. Suppose we want to generate T(n), then the formula will be like below −T(n) = T(n ... Read More

Hamming Distance in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 11:05:39

4K+ Views

Consider we have two integers. We have to find the Hamming distance of them. The hamming distance is the number of bit different bit count between two numbers. So if the numbers are 7 and 15, they are 0111 and 1111 in binary, here the MSb is different, so the ... Read More

Fizz Buzz in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 11:03:59

4K+ Views

Suppose we have a number n. We have to display a string representation of all numbers from 1 to n, but there are some constraints.If the number is divisible by 3, write Fizz instead of the numberIf the number is divisible by 5, write Buzz instead of the numberIf the ... Read More

Range Sum Query - Immutables in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 10:50:14

173 Views

Suppose we have an array of integers. We have to find the sum of the elements present from index i to j. Two things we have to keep in mind that the array will be immutable, so elements will not be altered, and there will be multiple such queries. So ... Read More

Move Zeroes in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 10:46:18

1K+ Views

Suppose we have an array to hold some numbers. There are non-zero values as well as zero values. So we have to send all zeros to the right without changing the relative order of other numbers. So if the array is like [0, 1, 5, 0, 3, 8, 0, 0, ... Read More

Missing Number in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 10:43:48

439 Views

Suppose we have a list of numbers from 0 to n. There is one number that is missing. We have to find the missing number in an efficient approach. So if A = [0, 1, 2, 3, 4, 5, 7, 8, 9], missing number is 6.To solve this, we will ... Read More

Advertisements