Shubham Vora has Published 962 Articles

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

Shubham Vora

Shubham Vora

Updated on 16-Oct-2023 17:35:07

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

Count Substrings with even frequency of each character and one exception

Shubham Vora

Shubham Vora

Updated on 16-Oct-2023 17:27:46

102 Views

In this problem, we will count the number of substrings of the given string containing all characters with even frequency or any single character with odd frequency. We will use the bitmasking technique to solve the problem. In bitmasking, each bit of the binary string represents the character. ... Read More

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

Shubham Vora

Shubham Vora

Updated on 16-Oct-2023 16:57:47

59 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. ... 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 15:25:08

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

How to use Hashmap in TypeScript?

Shubham Vora

Shubham Vora

Updated on 07-Oct-2023 03:14:43

29K+ 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 ... Read More

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

Shubham Vora

Shubham Vora

Updated on 05-Oct-2023 13:00:47

58 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. ... 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 12:58:55

33 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 ... 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 12:57:12

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

Find index of pair among given pairs with just greater average

Shubham Vora

Shubham Vora

Updated on 05-Oct-2023 12:55:38

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

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

Shubham Vora

Shubham Vora

Updated on 05-Oct-2023 12:51:25

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

Advertisements