Shubham Vora has Published 957 Articles

Print updated levels of each node of a Complete Binary Tree based on difference in weights of subtrees

Shubham Vora

Shubham Vora

Updated on 25-Aug-2023 16:04:10

104 Views

In this problem, we will update the level of each child node based on the left and right subtree's weight difference. Here, we will recursively traverse the subtree of each node to get the weight of the left and right subtree. After that, we will again traverse each subtree node ... Read More

Print Nth Stepping or Autobiographical number

Shubham Vora

Shubham Vora

Updated on 25-Aug-2023 16:02:24

312 Views

In this problem, we will print the Nth Stepping number. The naïve approach for solving the problem is to traverse natural numbers, check whether each number is a Stepping number, and find the Nth Stepping number. Another approach can be using the queue data structure. Problem Statement We have ... Read More

Print all Exponential Levels of a Binary Tree

Shubham Vora

Shubham Vora

Updated on 25-Aug-2023 16:01:21

183 Views

In this problem, we will print all exponential levels of the binary tree. We will use the level order traversal to traverse through each level of the binary tree. After that, we will find minimum P and q values using the first element of the level. In the next ... Read More

Minimum difference between maximum and minimum value of Array with given Operations

Shubham Vora

Shubham Vora

Updated on 25-Aug-2023 16:00:17

278 Views

In this problem, we will find the minimum difference between minimum and maximum array elements after multiplying or dividing any array elements with K. The simple approach to solving the problem is dividing each element of the array with K if divisible, multiplying each element with K, and tracking the ... Read More

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 15:59:09

158 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 ... Read More

Python3 Program for Queries for Rotation and Kth Character of the given String in Constant Time

Shubham Vora

Shubham Vora

Updated on 25-Aug-2023 15:57:46

121 Views

In this problem, we need to perform the queries according to the given rules and print the characters from the updated string. We will solve the problem using two different approach. In the first approach, we will use the string rotation concept, and in the second approach, we will use ... Read More

Implementing Water Supply Problem using Breadth First Search

Shubham Vora

Shubham Vora

Updated on 25-Aug-2023 15:57:37

207 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 ... Read More

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

Shubham Vora

Shubham Vora

Updated on 25-Aug-2023 15:56:00

105 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 ... Read More

Clockwise Triangular traversal of a Binary Tree

Shubham Vora

Shubham Vora

Updated on 25-Aug-2023 15:54:54

263 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 ... Read More

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

Shubham Vora

Shubham Vora

Updated on 25-Aug-2023 15:53:45

147 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 ... Read More

Advertisements