Arnab Chakraborty has Published 4452 Articles

Program to find minimum operations to reduce X to zero in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2021 12:34:15

291 Views

Suppose we have an array called nums and another value x. In one operation, we can either delete the leftmost or the rightmost element from the array and subtract the value from x. We have to find the minimum number of operations required to reduce x to exactly 0. If ... Read More

Program to count minimum deletions needed to make character frequencies unique in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2021 12:26:07

202 Views

Suppose we have a string s, s is said to be good if there are no two different characters in s that have the same frequency. We have to find the minimum number of characters we need to delete to make s a good string.So, if the input is like ... Read More

Program to count sorted vowel strings in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2021 12:22:05

551 Views

Suppose we have a number n, we have to find the number of strings of size n that consist only of vowels (a, e, i, o, u) and they are lexicographically sorted. We can say that a string s is lexicographically sorted when for all valid index i, s[i] is ... Read More

Program to count substrings that differ by one character in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2021 12:02:37

172 Views

Suppose we have two strings s and t, we have to find the number of ways we can select a nonempty substring of s and replace one single character by another different character such that the resulting substring is one of the substring of t. We have to find the ... Read More

Program to find path with minimum effort in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2021 11:51:58

324 Views

Suppose we have 2D matrix of order m x n called height. The heights[i][j] represents the height of cell (i, j). If we are at (0, 0) cell we want to travel to the bottom-right cell, (m-1, n-1). We can move up, down, left, or right, and we wish to ... Read More

Program to find best team with no conflicts in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2021 11:40:57

363 Views

Suppose we have two lists called scores and ages, where scores[i] and ages[i] represents the score and age of the ith player in a basketball game. We want to select the team with the highest overall score. Here the score of the team is the total sum of scores of ... Read More

Program to find lexicographically smallest string after applying operations in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2021 11:25:54

186 Views

Suppose we have a string s with only numeric digits and also have two values a and b. We can apply any one of the following two operations any number of times and in any order on s −Add 'a' to all odd positioned items of s(0-indexed). If digit is ... Read More

Program to find number of sets of k-non-overlapping line segments in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2021 11:16:36

218 Views

Suppose we have n points on a line, where the ith point (from 0 to n-1) is at position x = i, we have to find the number of ways we can draw exactly k different non-overlapping line segments such that each segment covers two or more points. The endpoints ... Read More

Program to find maximal network rank in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2021 10:54:28

342 Views

Suppose there are n cities and there are some roads connecting these cities. Each roads[i] = [u, v] indicates that there is a two-way road between cities u and v. Now consider network rank is the total number of directly connected roads to either city. When a road is directly ... Read More

Program to find valid matrix given row and column sums in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Oct-2021 13:15:42

218 Views

Suppose we have two arrays rowSum and colSum with non-negative values where rowSum[i] has the sum of the elements in the ith row and colSum[j] has the sum of the elements in the jth column of a 2D matrix. We have to find any matrix with non-negative values of size ... Read More

Advertisements