Sub-string that contains all lowercase alphabets after performing the given operation
Given a string str containing lower case alphabets and character ‘?’. The task is to check if it is possible to make str good or not.A string is called good if it contains a sub-string of length 26 which has every character of lower case alphabets in it. The task is to check if it is possible to make the string good by replacing ‘?’ characters with any lower case alphabet. If it is possible then print the modified string otherwise print -1....
read more
Why is Conversion From String Constant to ‘char*’ Valid in C but Invalid in C++?
In both C and C++, strings are sequences of characters enclosed in double-quotes. In this article, we will learn why is the conversion from string constant to ‘char*’ valid in C but invalid in C++....
read more
Implementation of C++ Bitset using String
Let’s implement bitset in C++, such that following operations can be performed in stated time complexities :...
read more
Prime String
Given a String str , the task is to check if the sum of ASCII value of all characters is a Prime Number or not....
read more
Check divisibility of binary string by 2^k
Given a binary string and a number k, the task is to check whether the binary string is evenly divisible by 2k or not....
read more
Check if expression contains redundant bracket or not | Set 2
Given a string of balanced expressions, find if it contains a redundant parenthesis or not. A set of parenthesis is redundant if the same sub-expression is surrounded by unnecessary or multiple brackets. Print ‘Yes’ if redundant else ‘No’.Note: Expression may contain ‘+’, ‘*‘, ‘–‘ and ‘/‘ operators. Given expression is valid and there are no white spaces present.Note: The problem is intended to solve in O(1) extra space....
read more
stringstream in C++ and its Applications
A stringstream associates a string object with a stream allowing you to read from the string as if it were a stream (like cin). To use stringstream, we need to include sstream header file. The stringstream class is extremely useful in parsing input....
read more
Program to reverse words in a given string in C++
Given a sentence in the form of string str, the task is to reverse each word of the given sentence in C++. Examples:...
read more
Longest substring that starts with X and ends with Y
Given a string str, two characters X and Y. The task is to find the length of the longest substring that starts with X and ends with Y. It is given that there always exists a substring that starts with X and ends with Y. Examples:...
read more
Minimum cost to convert given string to consist of only vowels
Given string str of lower case alphabets, the task is to find the minimum cost to change the input string in a string that contains only vowels. Each consonant is changed to the nearest vowels. The cost is defined as the absolute difference between the ASCII value of consonant and vowel....
read more
Check if given string is a substring of string formed by repeated concatenation of z to a
Given a string str, the task is to check if string str is a substring of an infinite length string S in which lowercase alphabets are concatenated in reverse order as:...
read more
How to Convert a C++ String to Uppercase?
In C++, converting a string to uppercase means we have to convert each character of the string that is in lowercase to an uppercase character. In the article, we will discuss how we can convert a string to uppercase in C++....
read more