Shubham Vora has Published 962 Articles

Rearrange and Update Array Elements as Specified by the given Queries

Shubham Vora

Shubham Vora

Updated on 22-Jul-2023 12:36:30

138 Views

In this problem, we will perform the given queries on the array elements. The queries contain the circular left rotation, right rotation, and updation of the array element. The logical part of solving the problem is array rotation. The naïve approach to rotating the array in the left direction is ... Read More

Print all Prime Levels of a Binary Tree

Shubham Vora

Shubham Vora

Updated on 22-Jul-2023 12:20:22

68 Views

In this problem, we will print all prime levels of the given binary tree. We will use the level order traversal technique to traverse each binary tree level and check whether all nodes contain the prime integer for the particular level. Problem statement − We have given a binary ... Read More

Print all Palindromic Levels of a Binary Tree

Shubham Vora

Shubham Vora

Updated on 22-Jul-2023 12:17:34

97 Views

In this problem, we will print each palindromic level of the given binary tree. We can use the breadth−first search algorithm to traverse each level of the given binary tree and check whether a particular level of the binary tree is palindromic. If yes, we print the level in the ... Read More

Print all Nodes Except Rightmost Node of Every Level of the Binary Tree

Shubham Vora

Shubham Vora

Updated on 22-Jul-2023 12:12:36

55 Views

In this problem, we will print all the nodes of the binary tree except the rightmost node of each level. We will use the level order traversal to traverse the binary tree, and we won’t print the last node of each level, which is the rightmost node. Problem statement − ... Read More

Minimize the Maximum difference between Adjacent Elements in an Array

Shubham Vora

Shubham Vora

Updated on 22-Jul-2023 12:06:48

388 Views

In this problem, we will minimize the maximum difference between adjacent elements by removing any M elements from the array. The naïve approach to solving the problem is to pick total N − M array elements and check which set contains the minimum or maximum adjacent difference. The optimized approach ... Read More

Iterative Method to Find Height of Binary Tree

Shubham Vora

Shubham Vora

Updated on 21-Jul-2023 21:51:02

296 Views

The binary tree is a data structure. Each node of the binary tree contains either 0, 1, or 2 nodes. So, the binary tree can contain multiple levels. Here, we need to write the iterative code using the loops to find the height of the binary tree. The total number ... Read More

How to Efficiently Implement k Queues in a Single Array?

Shubham Vora

Shubham Vora

Updated on 21-Jul-2023 21:47:38

193 Views

In some cases, we need to implement our own data structure for better usability and customization. Here, we need to implement the K Queues using the single array. The first solution that comes to mind is dividing the array into N/K parts and using each part of the array as ... Read More

Sum of numbers formed by consecutive digits present in a given string

Shubham Vora

Shubham Vora

Updated on 18-Jul-2023 17:31:33

215 Views

Problem Statement We have given a string str containing the numeric and alphabetical characters. We need to find the sum of all numbers represented by a continuous sequence of digits available in the given string. Sample Examples Input str = “12were43” Output 55 Explanation The sum of 12 ... Read More

Modify a Sentence By Reversing Order Of Occurrences Of All Palindrome Words

Shubham Vora

Shubham Vora

Updated on 18-Jul-2023 17:27:29

94 Views

Problem Statement We have given a string str containing a total of N words. We need to find all palindrome words in the given string and create a new string by reversing the order of all palindrome words. Sample Examples Input str = ‘nayan was gone to navjivan eye hospital’ ... Read More

Minimum Removals Required To Place All 0s Before 1s In a Binary String

Shubham Vora

Shubham Vora

Updated on 18-Jul-2023 17:25:35

125 Views

Problem Statement We have given binary string str, and we require to remove minimum characters from the string such that we can place all zeros before 1. Sample Examples Input str = ‘00110100111’ Output 3 Explanation Here, we can achieve output 3 in two ways. We can ... Read More

Advertisements