Given a string and number of rows ‘n’. Print the string formed by concatenating n rows when input string is written in row-wise Zig-Zag fashion.
An edit between two strings is one of the following changes. Add a character Delete a character Change a character Given two string s1 and s2, find if s1 can be converted to s2 with exactly one edit. Expected time complexity is O(m+n) where m and n are lengths of two strings. Examples: Input: s1… Read More »
Given a string, that contains special character together with alphabets (‘a’ to ‘z’ and ‘A’ to ‘Z’), reverse the string in a way that special characters are not affected. Examples: Input: str = “a,b$c” Output: str = “c,b$a” Note that $ and , are not moved anywhere. Only subsequence “abc” is reversed Input: str =… Read More »
Given a string consisting of opening and closing parenthesis, find length of the longest valid parenthesis substring. Examples: Input : ((() Output : 2 Explanation : () Input: )()()) Output : 4 Explanation: ()() Input: ()(())))) Output: 6 Explanation: ()(())) We strongly recommend you to minimize your browser and try this yourself first. A Simple… Read More »
Two strings str1 and str2 are called isomorphic if there is a one to one mapping possible for every character of str1 to every character of str2.
Given a string, find all possible palindromic partitions of given string. Example: We strongly recommend you to minimize your browser and try this yourself first. Note that this problem is different from Palindrome Partitioning Problem, there the task was to find the partitioning with minimum cuts in input string. Here we need to print all… Read More »
Given a string of odd length, print the string X format.
Given two strings A and B, the task is to convert A to B if possible. The only operation allowed is to put any character from A and insert it at front.
Given a set of n strings arr, find the smallest string that contains each string in the given set as substring. We may assume that no string in arr is substring of another string.
Given a string, remove all spaces from the string and return it. Input: “g eeks for ge eeks ” Output: “geeksforgeeks”
Given a stream of characters (characters are received one by one), write a function that prints ‘Yes’ if a character makes the complete string palindrome, else prints ‘No’.