Arnab Chakraborty has Published 4452 Articles

Program to find out the maximum value of a 'valid' array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:45:25

168 Views

Suppose, we have an array of n integers 'nums'. Each value in 'nums' represent its 'power'. The array will be evaluated 'valid' if the length of the array is greater than two and the first and last value of the array is equal. We have to make the array valid ... Read More

Program to find maximum score of a good subarray in Python

Arnab Chakraborty

Arnab Chakraborty

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

373 Views

Suppose we have an array called nums and a value k. Consider the score of a subarray (i, j) is defined as minimum of subarray nums[i..j] * (j-i+1). Now, a good subarray is a subarray where i -1 and nums[i] >= minNum, doi := i - 1while j < ... Read More

Program to make the XOR of all segments equal to zero in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:40:13

222 Views

Suppose we have an array called nums and another value k. The XOR of a segment [left, right] (left 0, thenfor each index j and value prev in dp, donew_dp[i XOR j] := maximum of new_dp[i XOR j] and prev+cntdp := new_dpreturn size of nums - new_dp[0]ExampleLet us see ... Read More

Program to find out if a vertex in an undirected graph has a lesser cost path in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:40:01

106 Views

Suppose, we are given a weighted, undirected graph. We have to implement a function query that takes two vertices and a cost 'limit' as input and checks if there exists a lower cost path than the cost given as input. We return true if there exists a path or otherwise, ... Read More

Program to find length of longest chunked palindrome decomposition in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:37:58

78 Views

Suppose we have a text. We have to find the largest possible k such that there exists a[1], a[2], ..., a[k] such that: Each a[i] is a string which is not blank. And their concatenation a[1] + a[2] + ... + a[k] is equal to the given text; For all ... Read More

Program to find max chunks to make array sorted in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:34:58

147 Views

Suppose we have an array nums, we have to split the array into some number of partitions, and individually sort each of them. Now after concatenating them we will get one sorted array. We have to find the maximum number of partitions we could have made?So, if the input is ... Read More

Program to find out the sum of evenly spaced elements in an array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 07:33:29

246 Views

Suppose, there is an array 'nums' of size n containing positive integers. We have another array 'queries' that contain integer pairs (pi, qi). For every query in the array queries, the answer will be the sum of numbers in the array nums[j] where pi

Program to find maximize palindrome length from subsequences in Python

Arnab Chakraborty

Arnab Chakraborty

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

115 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

458 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

82 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

Advertisements