Shubham Vora

Shubham Vora

793 Articles Published

Articles by Shubham Vora

Page 45 of 80

Find the String Among given Strings Represented using given Encryption Pattern

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

In this problem, we need to find the original string from the encrypted string using the given encryption rules. We can get the original string if we use the encryption rules in reverse order. Problem statement – We have given an encrypted string. Also, we have given an array of strings containing multiple strings. We need to find the string from the array, so if we encrypt according to the below rules, we can get the encrypted string. Encryption rules The encrypted string should start with a positive integer, representing a number of uppercase letters in the original string. ...

Read More

Find Largest Valued Even Integer which is a Non-Empty Substring of S

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

In this problem, we need to find the largest even valued substring of the given string. The even string always contains the 2, 4, 6, 8, 0 at last. So, we can take all substrings of the given string, and if any substring is even and greater than the maximum substring, we can update the maximum substring value. Problem statement – We have given string str containing numeric digits only. We need to find the largest substring of the str, which is an even integer value. Sample examples Input str = "1234789" Output 123478 Explanation ...

Read More

Encoding a Sentence into Pig Latin

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

In this problem, we will convert the sentence into Pig Latin. We can append the first character of each word at the last and append ‘ay’ after that. We will see three approaches to convert the given sentence into the Pig Latine. The logic is we can append the first character at the end and remove it from the string. After that, we can append ‘ay’ to the word. Problem statement – We have given a string alpha containing multiple words. We need to encode the string into Pig Latin. Note – The Pig Latine is a word encryption ...

Read More

Check if Words in given Sentence Occur based on the given Pattern

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

In this problem, we need to check whether the string follows the given pattern. We can solve the problem by mapping each character to the word. If any character of the pattern maps more than one word, we can say that the string is not following the pattern. Problem statement – We have given a ‘pat’ string containing N characters and an ‘alpha’ string containing N words. The given task is to check whether the ‘alpha’ string follows the pattern of the ‘pat’ string. Note – We can say that the ‘alpha’ string follows the pattern when the word matches ...

Read More

Shortest String formed by Concatenating String A x Times and B y Times such that n(A)x = n(B)*y

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

In this problem, we need to find the shortest string, which is a multiple of string A and string B. The problem is very similar to finding the LCM (Least common multiplier) of two numbers. We can find the LCM of both strings’ lengths and make both strings’ lengths equal to LCM by concatenating to itself. After that, we can compare the string to check if it is possible to get the shortest string which multiple of A and B. Problem statement – We have given string A and string B of different lengths. We need to find the shortest ...

Read More

Sum and product of K smallest and largest Fibonacci numbers in the array

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

In this problem, we will find the sum and product of the K maximum and minimum Fibonacci numbers in the array. The given problem is very basic and aims to focus on improving the problem-solving skills of beginners. The main goal of the problem is to introduce how to filter the Fibonacci numbers from the given array of elements and sum and product minimum and maximum Fibonacci numbers. Problem Statement We have given a nums[] array containing the N integer values. Also, we have given K positive integer. We need to find the sum and product of the K minimum ...

Read More

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 166 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 to update its level according to the difference in weight of the left and right sub-tree. Problem Statement We have given a complete binary tree containing N levels and 2N -1 nodes. The levels are numbered from 0 to N − 1 in decreasing order (0, -1, -2, -3, etc.). ...

Read More

Print Nth Stepping or Autobiographical number

Shubham Vora
Shubham Vora
Updated on 25-Aug-2023 377 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 given a positive integer N. We need to print the Nth Stepping number. The number is called a Stepping number if the difference between two adjacent digits of a number is 1. Sample Examples Input N = 15 Output 34 Explanation The Stepping numbers are 1, 2, ...

Read More

Print all Exponential Levels of a Binary Tree

Shubham Vora
Shubham Vora
Updated on 25-Aug-2023 280 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 step, we can check whether other level values are exponential. Problem Statement We have given a binary tree. We need to print values of all exponential levels of the binary tree. It is given if the values of each node of the level of the binary tree are equal ...

Read More

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

Shubham Vora
Shubham Vora
Updated on 25-Aug-2023 382 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 array's minimum and maximum elements. Problem Statement We have given array nums[] containing the integer values and positive integer K. We can multiply any number of the nums[] array with K or divide it by K if it is divisible. The given task is to find the minimum difference between ...

Read More
Showing 441–450 of 793 articles
« Prev 1 43 44 45 46 47 80 Next »
Advertisements