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”)
We have already seen the problem to print first repeating character in a string. In this post we will be looking at printing all the repeating characters in the string. For example: Input String: “www.ritambhara.in” Output: w.ria Input String: “social.ritambhara.in” Output: ia.r Input String: “meenakshi” Output: e Note that we are printing the repeating character […]
Give a string in which characters may be repeating. Print the first character (from the start) which is repeating in the string. For example: String: ABCBCD Output: B (A is not repeating, hence B is the first character which is repeating) String: ABCDE Output: NULL (No character repeating)