Arnab Chakraborty has Published 4293 Articles

Program to find length of longest diminishing word chain in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 09:08:50

197 Views

Suppose we have a list of valid words, and have a string s also, we have to find the length of the longest chain of diminishing words that can be generated by starting at s and removing single letters and still make valid words.So, if the input is like words ... Read More

Program to find cost to remove consecutive duplicate characters with costs in C++?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 09:07:01

465 Views

Suppose we have a string with lowercase letters and we also have a list of non-negative values called costs, the string and the list have the same length. We can delete character s[i] for cost costs[i], and then both s[i] and costs[i] is removed. We have to find the minimum ... Read More

Program to print maximum number of characters by copy pasting in n steps in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 09:00:23

115 Views

Suppose we have a number n; we have to find the maximum number of characters we can enter using n operations where each operation is likeInserting the character "x".Copy all characters.PasteSo, if the input is like n = 12, then the output will be 81.To solve this, we will follow ... Read More

Program to count minimum number of operations required to make numbers non coprime in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 08:57:53

323 Views

Suppose we have two numbers A and B. Now in each operation, we can select any one of the number and increment it by 1 or decrement it by 1. We have to find the minimum number of operations we need such that the greatest common divisor between A and ... Read More

Program to find next state of next cell matrix state in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 08:54:17

184 Views

Suppose we have a 2D binary matrix where a 1 means a live cell and a 0 means a dead cell. A cell's neighbors are its immediate horizontal, vertical and diagonal cells. We have to find the next state of the matrix using these rulesAny living cell with two or ... Read More

Program to remove all nodes with only one child from a binary tree in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 08:51:15

700 Views

Suppose we have a binary tree root; we have to remove all nodes with only one child.So, if the input is likethen the output will beTo solve this, we will follow these steps:Define a method called solve(), this will take tree rootif root is null, thenreturn rootif left of root ... Read More

Program to find length of longest possible stick in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 08:47:08

280 Views

Suppose we have a list of integers sticks. Here each element in the list represents a stick with two ends, these values are between 1 and 6. These are representing each end. We can connect two sticks together if any of their ends are same. The resulting stick's ends will ... Read More

Program to find a matrix for each condominium's height is increased to the maximum possible height in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 08:44:10

267 Views

Suppose we have a 2D matrix, where matrix [r, c] represents the height of a condominium in a city. The west-east skyline is visible by taking the maximum of each row in the matrix. And the north-south skyline can be visible by taking the maximum of each column. We have ... Read More

Program to find sum of concatenated pairs of all each element in a list in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 08:41:57

572 Views

Suppose we have a list of numbers called nums. We have to find the sum of every concatenation of every pair of numbers in nums. Here the pair (i, j) and pair (j, i) are considered different.So, if the input is like nums = [5, 3], then the output will ... Read More

Program to find length of concatenated string of unique characters in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 08:36:22

262 Views

Suppose we have a list of strings words. We have to make a string that is constructed by concatenating a subsequence of words such that each letter is unique. We have to finally find the length of the longest such concatenation.So, if the input is like words = ["xyz", "xyw", ... Read More

Advertisements