Shubham Vora

Shubham Vora

793 Articles Published

Articles by Shubham Vora

Page 42 of 80

Find Strings formed by replacing prefixes of given String with given characters

Shubham Vora
Shubham Vora
Updated on 20-Oct-2023 233 Views

In this problem, we will form a triangle from the given string. The triangle will contain the rows equal to the string length - 1, and in each row, we replace the starting characters equal to the row number with '.' Character. We can use the loop to form each row of the string or string constructor and substr() method. Problem statement - We have given a string alpha. We need to print the string in the triangle pattern. We need to start the triangle with the alpha string and replace the first character of the previous string ...

Read More

Count ways to select three indices from Binary String with different adjacent digits

Shubham Vora
Shubham Vora
Updated on 16-Oct-2023 325 Views

In this problem, we will find the number of pairs of 3 indices so that any adjacent indices don’t have the same value in the pair. We can get the output by checking each pair of 3 indexes, but it can be more time-consuming. Another approach to solving the problem is to take the current index and also take the index from left and right, which doesn’t contain a similar value to the current index's value. This way, we can count the total number of pairs each index can form and sum them to get the output. Problem statement − ...

Read More

Count even indices of String whose prefix has prime number of distinct Characters

Shubham Vora
Shubham Vora
Updated on 16-Oct-2023 249 Views

In this problem, we will find total invalid characters in the given string. If total distinct characters till the particular even index is prime, we can say the character is invalid. We can use the map data structure to count the total number of distinct characters while traversing the string. Also, we can use the string of characters to keep track of the distinct digits. Also, for every character, we can check whether its index is even and whether distinct characters are prime. Problem statement – We have given a string alpha containing the N characters. We need to find ...

Read More

Check if String can be divided into two Subsequences so that product of sum is odd

Shubham Vora
Shubham Vora
Updated on 16-Oct-2023 220 Views

In this problem, we will check if it is possible to divide the given numeric string into two disjoint subsequences such that sum(sub1) * sum(sub2) becomes odd. We need to divide the string into two subsequences such that the sum of the digits of both becomes odd to get the odd multiplication result. Problem statement − We have given a string num_string containing the numeric characters. We need to check whether we can divide the string into two subsequences such that the multiplication of the sum of both subsequences becomes odd. Also, it is given that every character of the ...

Read More

How to use Hashmap in TypeScript?

Shubham Vora
Shubham Vora
Updated on 07-Oct-2023 45K+ Views

The Hashmap is the one kind of data structure that stores the key-value pairs of the different data.  Like other programming languages, TypeScript also contains a built-in map data structure. In JavaScript, we can't define the key or value type that needs to be stored in the map. So, we need to create a map of the generic type. In TypeScript, we can define the type of the key and value to be stored in the map. Syntax Following is the syntax create the map in TypeScript − let hashMap = new Map(); Parameters key_Type − It is ...

Read More

Maximum count of unique index 10 or 01 substrings in given Binary string

Shubham Vora
Shubham Vora
Updated on 05-Oct-2023 268 Views

In this problem, we will count the maximum number of 10 and 01 pairs that can be formed using the given binary string. To solve the problem, we can check the number of 10 and 01 pairs we can form using adjacent characters without sharing any characters in two pairs. Problem Statement We have given a bin_str binary string. We need to count the maximum number of 10 and 01 pairs we can make using the adjacent characters only. Also, we can use one character in any single pair. Two pairs can't share a single character. Sample Examples Input ...

Read More

C++ Program to Find the Mth element of the Array after K left rotations

Shubham Vora
Shubham Vora
Updated on 05-Oct-2023 192 Views

In this problem, we need to print the element from the given index after rotating the array for K times. This problem teaches us to find the element from the particular index in the rotational array. At first sight, the solution that comes to mind is that rotate the array for K times and access the Mth element, but we will also learn to access the Mth element in the rotational array without rotating the array. Problem Statement We have given arr[] array containing N numbers. Also, we have given the positive integer M and K. We need to rotate ...

Read More

Java Program to Find the Mth element of the Array after K left rotations

Shubham Vora
Shubham Vora
Updated on 05-Oct-2023 317 Views

In this problem, we will rotate the array by K left rotations and find the Mth element in the rotated array. The naïve approach to solve the problem is to rotate the array by K left rotation and take the element from the M – 1 index. The optimized approach is to find the final index value in such a way that the final index is the M – 1 index of the rotated array. Problem Statement We have given a nums[] array containing the positive integers. We have also given the positive integer K and M. We need ...

Read More

Find index of pair among given pairs with just greater average

Shubham Vora
Shubham Vora
Updated on 05-Oct-2023 186 Views

In this problem, we will find the index value for each pair such that the resultant pair's average value is just greater than the current pair's average value. To solve the problem, we will use the sorting algorithm and binary search technique. We will use a sorting algorithm to sort the array based on the pair's average value and a binary search algorithm to search a pair with a greater average value from the sorted array. Problem Statement We have given a pairs[] array containing the N pairs of positive integers. It is also given that the first element of ...

Read More

Count unique Strings by replacing Consonant with closest vowel and vice versa

Shubham Vora
Shubham Vora
Updated on 05-Oct-2023 208 Views

In this problem, we will count the number of unique strings we can generate by replacing each vowel with the closest consonant and each consonant with the closest vowel. We can find the number of choices for each character of the string to replace the current character with other characters. After that, we can multiply the number of choices of each character to get the answer. Problem Statement We have given an alpha string. We need to count the total number of different strings we can generate from the given string by performing the below operations on each character of ...

Read More
Showing 411–420 of 793 articles
« Prev 1 40 41 42 43 44 80 Next »
Advertisements