Given a string that has alphabets and special characters. Write code that reverse only the alphabets in the string and does not change the special characters. INPUT STRING: AB$C^%DEF* OUTPUT: FE$D^%CBA* We have discussed a simple code to reverse a string in this post. We use the same logic here, the only difference here is […]
Given a string of characters, search for a pattern (another smaller string) in the string. For example, if given string is Ritambhara Technologies for Coding Interviews and the pattern is Tech, then the pattern is present in the string. If the pattern that we are looking for is Moksha, then this pattern is not present […]
Given a string that may have white spaces, write code to remove all white spaces from than string. For example: Input String: “IT IS HOT OUTSIDE” Output String: “ITISHOTOUTSIDE” Input String: ” I T I S HOT ” Output String: “ITISHOT”
A valid mathematical expression can also have duplicate parenthesis as shown below: ((a+b)) (((a+(b)))+(c+d)) Write code to find if an expression has duplicate parenthesis. You may assume that expression does not have any white spaces.
In C language, string library has a function strcmp that takes two arguments and return -1, 0 or 1 depending on whether first string is less than equal-to or greater than the second string. int strcmp(const char *str1, const char *str2); Write similar function that compare strings given in the form of linked list, For […]
Given two strings, write a function which will print characters coming on only one of the two strings (and not both). The character may be repeated in that string. For example: String-1 String-2 Output ——— ———- ————- AFW BGF AWBG AFAAW BGFFB AWBG BGF AWBG AFW BGH AFWBGH AFW BGF AWBG
Write a function which will print the character coming maximum number of times in a given String. For example: Input String: ritambhara Output: a Because character ‘a‘ appears 3 times in the String.
Given a String in which characters may be repeating. Find the length of longest substring of where all characters are unique (non-repeating). For Example: If the String is “RITAMBHARA” Length of Longest substring with unique characters = 7 (“RITAMBH”)