Arnab Chakraborty has Published 4173 Articles

Program to find ways to make a fair array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2021 12:45:38

376 Views

Suppose we have an array called nums. We can select exactly one index and remove the element from that index. (The index of the elements may change after the removal). We can say an array is fair when the sum of the odd-indexed values equals the sum of the even-indexed ... Read More

Program to find smallest string with a given numeric value in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2021 12:39:59

541 Views

Suppose we have two values n and k. We have to find the lexicographically smallest string whose length is n and numeric value equal to k. The numeric value of a lowercase character is its position (starting from 1) in the alphabet, so the numeric value of character 'a' is ... Read More

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

Arnab Chakraborty

Arnab Chakraborty

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

406 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

308 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

755 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

291 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

481 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

566 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

338 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

375 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

Advertisements