wildcard character matching

Given two strings s1 and s2, where s1 contains wild card characters and s2 is a normal string. Write a function that will return true if both the given strings match The following wildcard characters are allowed ‘*’ = Matches with zero or more instances of any character or set …

Read more

Longest Palindromic Substring

Given a string, write a function that will find the longest palindromic substring Example INPUT  s = “ebcdcbn” OUTPUT “bcdcb” is the longest palindromic substring Method 1(Brute Force) : In this method we will pick all the substrings and check whether the substring is palindrom or not Time Complexity: O(n^3) …

Read more

Print all permutations with repetition

For the given input string, print all the possible permutations. Repetition of characters is allowed. We should print them in lexicographic order. Example a. Input string is: AB Output: AA AB BA BB Total 4 permutations. b. Input string is: ABC Output: AAA, AAB, AAC, ABA, ABB, ABC, ACA, ACB, …

Read more

Run length encoding

Run length encoding on the given input string. Example Input string is : “aaaabbbddddzz” Output string : a4b3d4z2 Here, a is coming 4 times, b is coming 3 times, d is coming 4 times and z is coming 2 times. Time complexity: O(n) Algorithm 1. Pick the first character from …

Read more

Translate »