Arnab Chakraborty has Published 4293 Articles

Program to find number of increasing subsequences of size k in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 09:44:40

482 Views

Suppose we have a list of numbers called nums and also another value k, we have to find the number of subsequences of size k that are strictly increasing. If the answer is very large, mod it by 10^9 + 7.So, if the input is like nums = [2, 3, ... Read More

Program to find cost to reach final index of any of given two lists in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 09:42:27

166 Views

Suppose we have two lists of numbers nums0 and nums1 of the same length and two other values d as distance and c as cost. If we start from index 0 at either nums0 or nums1 and want to end up at the final index of either list. Now, in ... Read More

Program to find minimum number of pins required to hang all banners in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 09:40:11

313 Views

Suppose we have a list of intervals of the form [start, end] this is representing the starts and end points of banners we want to hang. At least one pin is required to hang a banner, and one pin can hang more than once banners. We have to find the ... Read More

Program to count number of swaps required to group all 1s together in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 09:37:51

166 Views

Suppose we have a binary string, and we can swap any two bits. We have to find the minimum number of swaps required to group all 1s together.So, if the input is like s = "0111001", then the output will be 1, as We can perform these swaps: 0111001 -> ... Read More

Program to count number of queries that are true in a graph with weighted path in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 09:35:09

118 Views

Suppose we have an edge list for an undirected graph where each edge has [u, v, w] fields, u and v are source and destination vertices and w is the weight. And also have a list of queries of the same form [u, v, w]. That represents the question of ... Read More

Program to check whether first player can win a game where players can form string char by char in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 09:32:10

190 Views

Suppose we have a list of words. Now consider a ghost game where two players can participate into it. Here players alternate appending letters to a string. And the string that is being made must be a valid prefix of a word in the list, and the player who spells ... Read More

Program to check we can cross river by stones or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 09:29:42

363 Views

Suppose we have a list of sorted numbers called stones and this is representing the positions of stones on a river that we are trying to cross. To cross the river, we must finish at the last stone. Now in each step, we can jump (k - 1, k, or ... Read More

Program to find minimum number colors remain after merging in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 09:27:21

201 Views

Suppose we have a list of colors (R, G, B). Now if two different colors are there next to each other then they can transform into a single color item of the third color. We have to find the smallest number of them remaining after any possible sequence of such ... Read More

Program to find land with longest distance from water in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 09:25:00

192 Views

Suppose we have a binary matrix where, 0 represents water and 1 represents land. Now we have to find the land which has the longest Manhattan distance from water and finally return the distance.So, if the input is like1111110111110011then the output will be 3, as [0, 0] cell has Manhattan ... Read More

Program to get operations to convert one string to another in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Dec-2020 09:22:27

218 Views

Suppose we have two strings S and T. We have to find the shortest sequence of operations that changes S to T. Here the operations are basically either deleting or inserting a character.So, if the input is like S = "xxxy" T = "xxyy", then the output will be ["x", ... Read More

Advertisements