Shubham Vora

Shubham Vora

793 Articles Published

Articles by Shubham Vora

Page 17 of 80

Generate String after Adding Spaces at Specific Positions in a given String

Shubham Vora
Shubham Vora
Updated on 14-Aug-2023 382 Views

In this problem, we need to add spaces before the given indexes in the string. We can use two different approaches to solve the problem. The first approach moves the characters of the given string to add space at a particular index, and the second approach replaces the characters of the pre−initialize string with spaces. Problem statement − We have given string str of length N containing the alphanumeric characters. Also, we have given the spaceList array containing M positive integers representing the string index. We need to app space to the string before each index that exists in the ...

Read More

Find all Palindrome Strings in given Array of Strings

Shubham Vora
Shubham Vora
Updated on 14-Aug-2023 788 Views

We need to find all palindrome strings from the given array in this problem. The string is a palindrome if we can read it the same from the start and end. We can use two approaches to check whether the string is a palindrome. In the first approach, we reverse the string and compare it with the original string, and in the second approach, we keep comparing the string characters from start to last. Problem statement − We have given an array containing the N strings. We need to print all the strings of the array, which are palindrome. If ...

Read More

Decode a String Recursively Encoded as Count followed by Substring

Shubham Vora
Shubham Vora
Updated on 14-Aug-2023 431 Views

In this problem, we need to decode the given string by repeatedly adding the total count number of times. We can have three different approaches to solving the problem, and we can use two stacks or one stack to solve the problem. Also, we can solve the problem without using the two stacks. Problem statement − We have given a string str containing the opening and closing brackets, alphabetical and numeric characters. We need to decode the string recursively. Here are the patterns or rules to decode the string. [chars] − The ‘chars’ should appear count times in ...

Read More

Count the Number of Vowels and Consonants in a Linked List

Shubham Vora
Shubham Vora
Updated on 14-Aug-2023 334 Views

In this problem, we need to count the total vowels and constants in the given linked list. We can traverse the linked list and check for each character, whether it is a constant or vowel. Problem statement − We have given a linked list containing the lowercase alphabetical characters. We need to count the total number of vowels and constants in the linked list. Sample examples Input 'a' -> 'b' -> 'e', 'c' -> 'd' -> 'e' -> 'f'’ -> 'o' -> 'i' -> 'a' -> 'a' Output Vowel – 7, constant - 4 Explanation − ...

Read More

Count of each Lowercase Character after Performing described Operations for each Prefix of Length 1 to N

Shubham Vora
Shubham Vora
Updated on 14-Aug-2023 144 Views

In this problem, we need to perform the given operations with each string prefix. In the end, we need to count the frequency of each character. We can follow the greedy approach to solve the problem. We need to take each prefix of length K and update its characters according to the given conditions. We can use the map to count the frequency of characters in the final string. Problem statement − We have given the strings tr containing the N lowercase alphabetical characters. Also, we have given the mapping list, which contains total 26 elements. Each element is mapped ...

Read More

Check if a String is Present in the given Linked List as a Subsequence

Shubham Vora
Shubham Vora
Updated on 14-Aug-2023 288 Views

In this problem, we will check if the linked list contains the string as a subsequence. We can iterate the list and string together to check whether a string is present as a subsequence in the linked list. Problem statement − We have given a string of size N. Also, we have given a linked list of the dynamic length containing the alphabetical characters. We need to check whether the linked list contains the string as a subsequence. Sample examples Input 'e' -> 'h' -> 'e' -> 'k' -> 'h' -> 'e' -> 'l' ->'o' -> 'l' -> 'o' ...

Read More

C++ Program for Generating Lyndon Words of Length n

Shubham Vora
Shubham Vora
Updated on 14-Aug-2023 181 Views

In this problem, we need to generate the Lyndon words of the length n using the given characters. The Lyndon words are words such that any of its rotations is strictly larger than itself in the lexicographical order. Here are examples of Lyndon words. 01 − The rotations of ‘01’ is ‘10’, which is always strictly greater than ‘01’. 012 − The rotations of ‘012’ is ‘120’ and ‘210’, which is strictly greater than ‘012’. Problem statement − We have given an array s[] containing numeric characters. Also, we have given n representing the length ...

Read More

Sort array of strings after sorting each string after removing characters whose frequencies are not a powers of 2

Shubham Vora
Shubham Vora
Updated on 10-Aug-2023 185 Views

In this problem, we need to remove the characters from the string whose frequency is not the power of 2. After that, we need to sort each string of the array in non-increasing order. Problem statement- We have given an array arr[] containing total N strings of different lengths. We need to remove the character from the string if its frequency is not the power of 2. After that, we need to sort each string Sample examples Input – arr[] = {"abde", "cpcc", "ddddd", "kk"} Output – edba, p, kk Explanation In the string ‘abde’ string, all characters' frequency is ...

Read More

Reorder characters of a string to valid English representations of digits

Shubham Vora
Shubham Vora
Updated on 10-Aug-2023 154 Views

In this problem, we need to reorder the characters of a given string to valid English representations of digits. The first approach can be to find all permutations of the string, extract the English words related to numeric digits, and convert them to digits. Another approach that can be used to solve the problem is by finding one unique character from each word. In this tutorial, we will learn both approaches to solving the given problem. Problem statement- We have given a sting containing lowercase characters and a length equal to N. The string contains the English word representation of ...

Read More

Reduce a string to a valid email address of minimum length by replacing specified substrings

Shubham Vora
Shubham Vora
Updated on 10-Aug-2023 175 Views

In this problem, we have given the email string containing the ‘dot’ and ‘at’ words. We need to replace them with ‘.’ And ‘@’ characters. Note – The valid email address should contain the ‘@’ character only once. It should contain any prefixes before the ‘@’ character and the domain name after that. Also, a valid email can contain multiple ‘.’ Characters. Furthermore, the ‘@’ and ‘.’ Characters should not be at the start or end of the email address. Problem statement – We have given a string str containing the email address, and the length of the string is equal ...

Read More
Showing 161–170 of 793 articles
« Prev 1 15 16 17 18 19 80 Next »
Advertisements