Arnab Chakraborty has Published 4173 Articles

Program to find longest substring of all vowels in order in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 13:18:48

679 Views

Suppose we have a string s with only English vowels, we have to find the length of the longest beautiful substring of s. If we cannot find such substring then, return 0. A string is said to be beautiful if it satisfies the following conditions −Each of the 5 vowels ... Read More

Program to find frequency of the most frequent element in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 13:13:52

691 Views

Suppose we have an array nums and another value k. In one operation, we can select an index of nums and increase the element at that index by 1. We have to find the maximum possible frequency of an element after performing at most k number of operations.So, if the ... Read More

Program to find maximum ice cream bars in Python

Arnab Chakraborty

Arnab Chakraborty

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

725 Views

Suppose we have an array costs with n elements, where costs[i] is the price of the ith ice cream bar in coins. We initially have c number coins to spend, and we want to buy as many ice cream bars as possible. We have to find the maximum number of ... Read More

Program to find maximum XOR for each query in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 13:04:49

321 Views

Suppose we have an array which is presorted called nums of size n and also have one value b. We want to perform the following query n times −Search for a non-negative value k < 2^m such that XOR of all elements in nums and k is maximized. So k ... Read More

Program to find length of longest fibonacci subsequence in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 12:59:42

253 Views

Suppose we have one sequence like X_1, X_2, ..., X_n is fibonacci-like if −n >= 3X_i + X_i+1 = X_i+2 for all i + 2 last, thencome out from loopreturn bestExampleLet us see the following implementation to get better understanding −from collections import Counter def solve(A):    sA = ... Read More

Program to find total similarities of a string and its substrings in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 12:55:37

395 Views

Suppose we have a string s. We have to find the sum of similarities of string s with each of it's suffixes. Here the similarity between two strings are the length of the longest prefix common to both strings.So, if the input is like s = "pqpqpp", then the output ... Read More

Program to count number of nice subarrays in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 12:55:07

879 Views

Suppose we have an array called nums and another value k. We have to find the number of nice sub-arrays. A subarray is said to be nice subarray if there are k odd numbers on it.So, if the input is like nums = [1, 1, 2, 1, 1], k = ... Read More

Program to find minimum absolute sum difference in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 12:51:40

502 Views

Suppose we have two positive valued arrays nums1 and nums2, of same size. The absolute sum difference of these two arrays is the sum of |nums1[i] - nums2[i]| for each 0 [2, 2, 6], orReplace the element at index 1 with the element at index 2: [2, 8, 6] ... Read More

Program to get maximum length merge of two given strings in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 12:48:18

254 Views

Suppose we have two strings s and t. We have to make a string called merge in the following way: while either s or t are non-empty, select one of the following options −If s is non-empty, then append the first character in s to merge and delete it from ... Read More

Program to count nice pairs in an array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 07-Oct-2021 12:44:31

425 Views

Suppose we have an array called nums with non-negative values. We have to find number nice pairs of indices present in the array, if the answer is too large, then return answer mod 10^9+7. Here a pair of indices (i, j) is said to be nice when they satisfy all ... Read More

Advertisements