Shubham Vora has Published 793 Articles

Maximum Product of First and Last Character of String after Rotation

Shubham Vora

Shubham Vora

Updated on 17-Jul-2023 16:22:35

153 Views

In this problem, we will find the maximum possible product of the first and last digits of the string by rotating the string multiple times. The naïve approach is that find all rotations of the string, take the product of the first and last character, and choose the maximum product ... Read More

Make Binary Strings Equal by Replacing 2nd Bit Repeatedly

Shubham Vora

Shubham Vora

Updated on 17-Jul-2023 16:19:04

190 Views

In this problem, we need to convert the bin1 string to the bin2 string by replacing the second character of the bin1 string with the minimum or maximum of the first and second characters and removing the first character. As we need to remove the initial character, we need to ... Read More

Longest Substring of given Characters by Replacing at Most K Characters for Q Queries

Shubham Vora

Shubham Vora

Updated on 17-Jul-2023 16:14:29

270 Views

In this problem, we have given M queries, and after performing each query on the given string, we need to print the maximum length of the string having only the ‘ch’ character. We will use the tabulation method of dynamic programming to find the maximum possible length of the substring ... Read More

Longest Subsequence with Same Char as Substrings and Difference of Frequency at Most K

Shubham Vora

Shubham Vora

Updated on 17-Jul-2023 16:12:19

298 Views

In this problem, we will find the maximum length of the subsequence such that it should contain the contiguous characters, and the frequency difference of all characters won’t differ more than K. We need to find all possible subsequences of the given string and check whether it contains every character ... Read More

Generate Binary String with equal number of 01 and 10 Subsequence

Shubham Vora

Shubham Vora

Updated on 17-Jul-2023 16:06:05

499 Views

In this problem, we will find the binary string of the given length having the same number of ‘01’ and ‘10’ subsequences. The naïve approach to solving the problem is to generate all binary strings of the given length and check whether it contains the same number of ‘10’ ... Read More

Find Characters Which When Increased by K are Present in String

Shubham Vora

Shubham Vora

Updated on 17-Jul-2023 16:01:01

125 Views

In this problem, we will find all unique characters of the string with their first index, which is present in the string, after incrementing all characters of the given string by K. For a problem solution, we can take each unique character of the given string. Next, we can update ... Read More

Find all Words from String Present after Given N Words

Shubham Vora

Shubham Vora

Updated on 17-Jul-2023 12:54:21

236 Views

In this problem, we will find each word of the string which comes after all words of the ‘words’ array. The first approach to solve the problem is to split the string into words and match elements of the words[] array with the string words. If we find words[] array’s ... Read More

Find a Number Such that Sum of N with it is a Palindrome

Shubham Vora

Shubham Vora

Updated on 17-Jul-2023 12:46:17

267 Views

In this problem, we will find the string of length equal to the given string so that when we sum both strings, we get the palindromic strings. Here, we can find another string such that the sum of both becomes 99999…, the largest palindromic string of the same length. ... Read More

Count ways to Split String into K Substrings Starting with Even Digit and Min Length M

Shubham Vora

Shubham Vora

Updated on 17-Jul-2023 12:42:49

409 Views

In this problem, we will count ways to partition the given string into the K substrings such that it follows the condition given in the problem statement. We will use the recursion to solve the problem. Also, we will use the tabular dynamic programming approach to solve the problem efficiently. ... Read More

Count Substrings with Number of 0s and 1s in Ratio of X : Y

Shubham Vora

Shubham Vora

Updated on 17-Jul-2023 12:40:18

721 Views

In this problem, we will count substrings of the given binary string containing the number of ‘0’ and ‘1’ characters in the X : Y ratio. The naïve approach finds all substrings of the given binary string, counts ‘0’ and ‘1’, and checks whether the counts are in the X ... Read More

Advertisements