Arnab Chakraborty has Published 4293 Articles

Program to check whether we can reach last position from index 0 in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Oct-2020 13:40:03

212 Views

Suppose we have a list of numbers called nums where each number shows the maximum number of jumps we can make; we have to check whether we can reach to the last index starting at index 0 or not.So, if the input is like nums = [2, 5, 0, 2, ... Read More

Program to find longest consecutive run of 1 in binary form of a number in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2020 14:56:00

241 Views

Suppose we have a number n, we have to find the length of the longest consecutive run of 1s in its binary representation.So, if the input is like n = 312, then the output will be 3, as 312 is 100111000 in binary and there are 3 consecutive 1s.To solve ... Read More

Program to find minimum number of heights to be increased to reach destination in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2020 14:52:04

214 Views

Suppose we have a matrix M where M[r][c] represents the height of that cell. If we are currently at top left corner and want to go to the bottom right corner. We can move to adjacent cells (up, down, left, right) only if that the height of that adjacent cell ... Read More

Program to check whether a tree is height balanced or not in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2020 14:46:10

614 Views

Suppose we have a binary tree; we have to check whether its height is balanced or not. We know that for a height balanced tree, for every node in the tree, the absolute difference of the height of its left subtree and the height of its right subtree is 0 ... Read More

Program to group a set of points into k different groups in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2020 14:28:00

1K+ Views

Suppose we have a list of points and a number k. The points are in the form (x, y) representing Cartesian coordinates. We can group any two point p1 and p2 if the Euclidean distance between them is

Program to count number of strings we can make using grammar rules in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2020 14:22:32

251 Views

Suppose we have a number n, we have to find the number of strings of length n can be generated using the following rules −Each character is a lower case vowel [a, e, i, o, u]"a" may only be followed by one "e""e" may only be followed by any of ... Read More

Program to find total mutation group of genes in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2020 14:17:07

357 Views

Suppose we have a list of strings called genes where each element has the same length and each element contains characters "A", "C", "G" and/or "T". Now there are some rules −When two strings s1 and s2 are the same string except for one character, then s1 and s2 are ... Read More

Program to implement the fractional knapsack problem in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2020 14:10:45

2K+ Views

Suppose we have two lists, weights and values of same length and another value capacity. The weights[i] and values[i] represent the weight and value of ith element. So if we can take at most capacity weights, and that we can take a fraction of an item's weight with proportionate value, ... Read More

Program to check given graph is a set of trees or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2020 10:42:45

276 Views

Suppose we have a graph, represented as a list of edges. We have to check whether the graph is a collection of trees (forest) or not.So, if the input is likethen the output will be TrueTo solve this, we will follow these steps −Define a function dfs() . This will ... Read More

Program to find correct order of visited cities in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2020 10:32:22

215 Views

Suppose we have a list of airline tickets represented by pairs of departure and arrival airports like [from, to], we have to reconstruct the itinerary in correct order. All of the tickets belong to a man who departs from KLK. So, the itinerary must begin with JFK.So if the input ... Read More

Advertisements