Shubham Vora has Published 793 Articles

Count of Prime Factors of N to be Added at each Step to Convert N to M

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:22:47

176 Views

In this problem, we will convert the number N to M by adding the one prime factor of N to itself and updating it in each operation. We will use the breadth−first search algorithm to solve the problem. We will find the prime factor of each updated N and insert ... Read More

Construct Complete Binary Tree from its Linked List Representation

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:11:14

823 Views

In this problem, we will convert the linked list to the complete binary tree. We can assume the linked list as an array. The pth element of the linked list is the parent node of the binary tree's 2*p + 1 and 2*p + 2 elements. So, we can traverse ... Read More

Check if the given Permutation is a Valid BFS of a Given Tree

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:05:45

354 Views

In this problem, we will check whether we can get the permutation of 1 to N elements given array using the BFS (Breadth−first search) traversal with the given binary tree. Here, we will traverse the tree and find all possible permutations using the BFS traversal. After that, we can ... Read More

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

183 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

380 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

346 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

207 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

272 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

406 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

Advertisements