Shubham Vora has Published 962 Articles

Find the Largest Multiple of 3 (Using Queue)

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:31:59

89 Views

In this problem, we will find the largest multiple of 3 using the array elements. The naïve approach is that generate all possible combinations of array elements and check whether it is divisible by 3. In this way, keep track of the maximum possible multiple of 3. The efficient ... Read More

Find the K Closest Points to Origin using Priority Queue

Shubham Vora

Shubham Vora

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

143 Views

In this problem, we will find the K nearest point from the origin in the 2D plane from the given N points. We can use the standard Euclidean distance formula to calculate the distance between the origin and each given point. After that, we can store the points with distance ... Read More

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

43 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

413 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

145 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

58 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

197 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

90 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

711 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

61 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

Advertisements