Arnab Chakraborty has Published 4173 Articles

Program to find maximize palindrome length from subsequences in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:30:15

214 Views

Suppose we have two strings, s and t. We want to make a string in the following manner −Select some non-empty subsequence sub1 from s.Select some non-empty subsequence sub2 from t.Concatenate sub1 and sub2, to make the string.We have to find the length of the longest palindrome that can be ... Read More

Program to count the number of ways to distribute n number of candies in k number of bags in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:27:51

595 Views

Suppose, there are n number of candies and k bags in which the candies have to put into. We have to find out the number of possible ways the candies can be distributed so that each bag contains at least one candy. Every candy in this scenario is unique, so ... Read More

Program to check whether one point can be converted to another or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:26:55

182 Views

Suppose we have a starting points (sx, sy), and target point (tx, ty), we have to check whether a sequence of moves exists from the start point to the end point. Here move consists of taking a point (x, y) and transforming it to either (x, x+y) or (x+y, y).So, ... Read More

Program to find smallest value of K for K-Similar Strings in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:24:31

282 Views

Suppose we have two strings s and t. These two strings are K-similar if we can swap the positions of two letters in s exactly K times so that the resulting string is t. So, we have two anagrams s and t, we have to find the smallest K for ... Read More

Program to find maximum subarray min-product in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:18:59

354 Views

Suppose we have an array nums, we have to find the maximum min-product of each non-empty subarray of nums. Since the answer can be big enough, return it in modulo 10^9+7. The min-product of the array is equal to the minimum value in the array multiplied by the sum of ... Read More

Program to find maximum distance between a pair of values in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:16:10

729 Views

Suppose we have two arrays (non-growing) nums1 and nums2. The index pair (i, j) with 0

Program to check whether we can split a string into descending consecutive values in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:12:02

291 Views

Suppose we have a string s with only numbers. We have to check whether we can split s into two or more non-empty substrings such that the numerical values of those substrings are in non-increasing sequence and the difference between numerical values of every two adjacent substrings is 1. So ... Read More

Program to find maximum element after decreasing and rearranging in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:07:56

236 Views

Suppose we have an array called arr. We have to perform some operations on arr so that it satisfies these conditions −The first element in arr must be 1.The absolute difference between any 2 adjacent elements must be at most 1.And there are two operations. We can perform these two ... Read More

Program to implement seat reservation manager in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:03:49

2K+ Views

Suppose we have to design a system that manages the reservation state of n seats. The seats are numbered from 1 to n. So we have to implement the SeatReserveManager class, with these functions −Constructor that takes n as input and initializes the object that will manage n seats numbered ... Read More

Program to find closest subsequence sum in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:00:04

530 Views

Suppose we have an array nums and another value goal. We want to select a subsequence of nums such that the sum of its elements is the nearest to goal. So in other words, if the sum of the subsequence's elements is s, then we want to minimize the absolute ... Read More

Advertisements