Shubham Vora has Published 793 Articles

Print all Palindromic Levels of a Binary Tree

Shubham Vora

Shubham Vora

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

241 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

190 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

815 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

789 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

501 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

746 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

219 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

523 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

Minimum Number That Can Be Obtained By Applying '+' And '*' Operations On Array Elements

Shubham Vora

Shubham Vora

Updated on 18-Jul-2023 17:16:15

177 Views

Problem Statement We have given an array of length ‘N’ containing some positive integers. Also, we have given the string of length ‘N-1’ containing only ‘*’ and ‘+’ characters, where ‘*’ is a multiplication operator, and ‘+’ is an addition operator. We require to perform the arithmetic operation with array ... Read More

Make a String Non-Palindromic By Inserting a Given Character

Shubham Vora

Shubham Vora

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

217 Views

Problem Statement We have given a string str and character c in the input. We need to insert the given character c in the string at the index so that we can convert the string to non-palindromic. If we can’t convert the string to non-palindrome, print ‘-1’. Sample Examples Input ... Read More

Advertisements