Shubham Vora has Published 957 Articles

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

223 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

258 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

421 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

96 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

180 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

220 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

351 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

659 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

Count Substrings that can be Made of Length 1 by Replacing "01" or "10" with 1 or 0

Shubham Vora

Shubham Vora

Updated on 17-Jul-2023 12:37:57

122 Views

In this problem, we will count substrings that we can make of length 1 by replacing the ‘10’ and ‘01’ substrings with ‘1’ or ‘0’ characters. When any binary string contains an equal number of ‘0’ and ‘1’, we can always make it of length 1 by performing the ... Read More

Check if given Morse Code is Valid

Shubham Vora

Shubham Vora

Updated on 17-Jul-2023 12:34:36

319 Views

In this problem, we will validate the Morse code. The Morse code method was used to transform the text in the encoded format, and it was very helpful to provide communication between two entities before the telephone was invented. There are standard codes for each alphabetical character containing the ‘.’ ... Read More

Advertisements