Shubham Vora has Published 957 Articles

Check if the End of the Array can be Reached from a given Position

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 12:58:23

144 Views

In this problem, we will check whether we can reach the array’s end by moving back or ahead by nums[p] moves from the current position. The naïve approach to solve the problem is to check all possibilities to move into the array and see if we can reach the array’s ... Read More

Segregate 1s and 0s in separate halves of a Binary String

Shubham Vora

Shubham Vora

Updated on 28-Jul-2023 13:10:17

319 Views

In this tutorial, we need to separate all 1s and 0s of the given binary string in the two halves. Here, we need to take a substring from the given string and reverse it to separate 0s and 1s in different parts. Ultimately, we need to count the total number ... Read More

Modify string by replacing all occurrences of given characters by specified replacing characters

Shubham Vora

Shubham Vora

Updated on 28-Jul-2023 13:07:54

254 Views

In this problem, we need to replace the characters of the given string according to the characters given in the array of pairs of characters. We will discuss two different approaches to solving the problem. In the first approach, we iterate through the characters of the given string and pairs ... Read More

Minimum removals required such that a string can be rearranged to form a palindrome

Shubham Vora

Shubham Vora

Updated on 28-Jul-2023 13:06:05

1K+ Views

In this problem, we need to remove the minimum characters from the string and rearrange the remaining characters to make the string palindromic. To solve the problem, the first question we should ask ourselves is when we can make string palindromic. In below two cases, we can make string palindromic. ... Read More

Minimize removal of substring of 0s to remove all occurrences of 0s from a circular Binary String

Shubham Vora

Shubham Vora

Updated on 28-Jul-2023 13:04:06

149 Views

In this problem, we require to remove all zeros from the given binary string. Also, we require to remove pair of consecutive zeros at once and count the total number of pairs of zeros removal. We can solve the problem by counting the number of pairs of consecutive zeros in ... Read More

Minimize flips required such that string does not any pair of consecutive 0s

Shubham Vora

Shubham Vora

Updated on 28-Jul-2023 12:58:09

211 Views

Here, we require to manipulate the binary string so that it doesn’t contain any consecutive zeros. If we find consecutive zeros, we need to change any zero to 1. So, we require to count the total number of 0 to 1 conversion we should make to remove all consecutive zeros ... Read More

Longest Non-Increasing Subsequence in a Binary String

Shubham Vora

Shubham Vora

Updated on 28-Jul-2023 12:55:09

346 Views

In this problem, we require to find the longest non-increasing subsequence of the given string. The meaning of non-increasing is either character should be the same or in decreasing order. As binary string contains only ‘0’ and ‘1’, the resultant string should start with ‘1’ and end with ‘0’, or ... Read More

Length of longest subset consisting of A 0s and B 1s from an array of strings

Shubham Vora

Shubham Vora

Updated on 28-Jul-2023 12:52:55

162 Views

In this problem, we need to find the longest subset containing at most A 0s and B1s. All we need to do is find all possible subsets using the array elements and find the longest subset containing maximum A 0s and B1. In this tutorial, first, we will learn the ... Read More

Construct a K-length binary string from an array based on given conditions

Shubham Vora

Shubham Vora

Updated on 28-Jul-2023 12:50:54

176 Views

In this tutorial, we require to construct a binary string of length K such that it should contain ‘1’ at the ith index if a subset-sum equal to I is possible using array elements. We will learn two approaches to solving the problem. In the first approach, we will use ... Read More

Check if a string can be split into 3 substrings such that one of them is a substring of the other two

Shubham Vora

Shubham Vora

Updated on 28-Jul-2023 12:48:15

161 Views

In this problem, we need to split the given string in such a way that the third substring can be a substring of the first two substrings. Let’s think about the solution. The third string can be a substring of the first two string only if the first two string ... Read More

Advertisements