Arnab Chakraborty has Published 4452 Articles

Program to find minimum swaps required to make given anagram in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:33:15

256 Views

Suppose we have two strings S and T and they are anagrams of each other. We have to find the minimum number of swaps required in S to make it same as T.So, if the input is like S = "kolkata" T = "katloka", then the output will be 3, ... Read More

Program to find nearest number of n where all digits are odd in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:31:25

481 Views

Suppose we have a number n, we have to find the next closest value where all digits are odd. When there are two values tied for being closest to n, return the larger one.So, if the input is like n = 243, then the output will be 199.To solve this, ... Read More

Program to find maximum difference of adjacent values after deleting k numbers in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:28:52

160 Views

Suppose we have a list of numbers called nums and they are sorted in ascending order, we have to delete k values from the list such that the maximum difference between any two adjacent values is as minimum as possible, and finally find the difference.So, if the input is like ... Read More

Program to find maximum credit we can get by finishing some assignments in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:27:39

389 Views

Suppose we have two lists of the same size, these are deadlines and credits and they are representing course assignments. Here deadlines[i] shows the deadline day for assignment i and credits[i] represents the amount of credits we get for assignment i. We have one day to complete an assignment, and ... Read More

Program to check number of ways we can move k times and return back to first place in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:26:10

79 Views

Suppose we are at position 0 of n length list, and on each step, we can move right one place or left one place (not exceeding bounds), or stay at the same position. Now if we can take exactly k steps, then we have to find how many unique walks ... Read More

Program to find number of steps to solve 8-puzzle in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:24:32

10K+ Views

Suppose we have a 3x3 board of where all numbers are in range 0 to 8 and no repeating numbers are there. Now, we can swap the 0 with one of its 4 neighbors, and we are trying to solve it to get all arranged sequence, we have to find ... Read More

Program to check whether we can form 24 by placing operators in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:22:21

66 Views

Suppose we have a list of four numbers, each numbers are in range 1 to 9, in a fixed order. Now if we place the operators +, -, *, and / (/ denotes integer division) between the numbers, and group them with brackets, we have to check whether it is ... Read More

Program to find number of days it will take to burn all trees in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:20:03

705 Views

Suppose we have a 2D matrix represents a forest where there are three types of cells: 0 empty cell 1 tree cell 2 tree on fire cell Every day, a tree catches fire when there is an adjacent (top, down, left, right, not diagonal) tree is on fire. We have ... Read More

Program to count number of paths whose sum is k in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:16:32

130 Views

Suppose we have a binary tree and another value k, we have to find the number of unique node to sub child paths are there which sums to k.So, if the input is likeand k = 5, then the output will be 2, as the paths are [2, 3] and ... Read More

Program to check whether we can color a tree where no adjacent nodes have the same color or not in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:15:00

162 Views

Suppose we have a binary tree where the value of each node represents its color. There are at most 2 colors in a tree. We have to check whether it is possible to swap the colors of the nodes any number of times so that no two connected nodes have ... Read More

Advertisements