Shubham Vora

Shubham Vora

793 Articles Published

Articles by Shubham Vora

Page 46 of 80

Minimum circular rotations to obtain a given numeric string by avoiding a set of given strings

Shubham Vora
Shubham Vora
Updated on 25-Aug-2023 244 Views

In this problem, we will find the number of rotations required to achieve the target string from the string containing N 0s. Also, we will skip the strings given in the array while making rotations. We can use the BFS algorithm to find the minimum rotations required to get the target string. Problem Statement We have given a target string containing the N numeric characters. Also, we have given the strs[] array containing the M strings of size N containing the numeric characters. We need to initially achieve the target string from a string containing N 0's by performing the ...

Read More

Implementing Water Supply Problem using Breadth First Search

Shubham Vora
Shubham Vora
Updated on 25-Aug-2023 309 Views

In this problem, we will find the maximum number of cities to which we can supply water. We can consider this problem as a graph traversing the blocked node. So, we can use the breadth-first search algorithm to find the maximum number of connected cities. Problem Statement We have given the total N cities. Also, we have given an edge between two cities; all cities are connected with any other single or multiple cities. We need to set up the water supply connection in each city. We have also given the blocked[] array containing the 0 and 1 values. ...

Read More

Find integral points with minimum distance from given set of integers using BFS

Shubham Vora
Shubham Vora
Updated on 25-Aug-2023 184 Views

In this problem, we will find the K points which are nearest to any of the given points from the points given in the array. To find the points which are nearest to the given points, we can take the nums[p] + 1 or nums[p] -1 for each element of the array if it is not present in the array. If we require more points, we can take the nums[p] + 2 or nums[p] – 2 points, and so on. Problem Statement We have given a nums[] array containing the N positive and negative integers. Each point of ...

Read More

Clockwise Triangular traversal of a Binary Tree

Shubham Vora
Shubham Vora
Updated on 25-Aug-2023 350 Views

In this problem, we will create a complete binary tree and traverse it in a circular clockwise direction. For the clockwise traversal, we can think of traversing the boundaries of the tree. For example, we can traverse the outer boundary of the tree first. After that, we can remove visited nodes and traverse the inner boundary of the tree. In this way, we need to make min(height/2, width/2) traversal of the given binary tree. Problem Statement We have given a complete binary tree containing N nodes and need to traverse it in a clockwise direction. Sample Examples Input n ...

Read More

Check if the Left View of the given tree is sorted or not

Shubham Vora
Shubham Vora
Updated on 25-Aug-2023 201 Views

In this problem, we will check whether the left view of the binary tree is sorted. The left view of the binary tree means nodes we can see when we look at the binary tree from the left side. In simple terms, we can see only the first node of each level. So, we need to extract the value of the first node and check whether they are sorted to get the output. Problem Statement We have given a binary tree. We need to print whether the binary tree's left view is sorted. If it is sorted, print 'Yes'. ...

Read More

Program to convert given Binary to its equivalent ASCII character string

Shubham Vora
Shubham Vora
Updated on 25-Aug-2023 702 Views

In this problem, we need to convert the binary string to the character string. We can convert the binary string to an ASCII number string first, and then we can convert the character string. Problem statement – We have given a binary string bin_str whose size is multiple of 8. We need to convert the binary string to the character string. Sample examples Input bin_str = "0110110001101010" Output 'lj' Explanation – The ‘01101100’ is equivalent to 108 in the decimal, which is equivalent to the ASCII value of the ‘l’. The ‘01101010’ equals 106, and ...

Read More

Check if cells numbered 1 to K in a grid can be connected after removal of atmost one blocked cell

Shubham Vora
Shubham Vora
Updated on 25-Aug-2023 184 Views

In this problem, we will check whether we can connect all K cells by unblocking any single cell. To solve the problem, we will assume all connected K as a single Island. If any single blocked cell can connect all Island of the matrix, it is only possible to connect all K cells of the matrix. So, If the matrix contains more than 4 Island, it is not possible to connect all cells. Problem Statement We have given a mat[] matrix of size n*m. We have also given a positive integer, K. The matrix contains 0 and -1 in ...

Read More

Minimum Number of Insertions in given String to Remove Adjacent Duplicates

Shubham Vora
Shubham Vora
Updated on 25-Aug-2023 187 Views

In this problem, we will count the minimum number of characters we need to insert to remove all adjacent duplicate characters. To solve the problem, we need to count the total number of adjacent duplicate character pairs. Problem statement – We have given a string named str containing N alphabetical characters. We need to find the total number of different characters we require to add to the string such that the resultant string shouldn’t contain any adjacent duplicated characters. Sample examples Input str = "ccddrt" Output 2 Explanation – We need to insert one character ...

Read More

Boundary Level order traversal of a Binary Tree

Shubham Vora
Shubham Vora
Updated on 25-Aug-2023 339 Views

In this problem, we will traverse each boundary of the given binary tree in the given order. We will use the recursive approach to traverse each boundary of the binary tree one by one. However, we will also learn the iterative approach using a stack to traverse the binary tree's boundary and increase the code's performance. Problem Statement We have given a binary tree, and we need to traverse each boundary of the tree in the given order. Traverse left boundary in top to bottom manner. Traverse bottom boundary from left to right. Traverse the right boundary from bottom ...

Read More

Minimum Jumps from Either End to Reach Largest and Smallest Character in given String

Shubham Vora
Shubham Vora
Updated on 25-Aug-2023 218 Views

In this problem, we require to find the minimum jumps required to make to reach the largest and smallest character in the given string. We can move to the next or previous character in one jump. We can solve the problem by finding the position of the lexicographically largest and smallest character in the given string. After that, we can find the minimum jumps required to the found indexes from the left and right sides. Problem statement – We have a string str of length N containing the alphabetical characters in the uppercase. We need to find the minimum number ...

Read More
Showing 451–460 of 793 articles
« Prev 1 44 45 46 47 48 80 Next »
Advertisements