Category Archives: Strings

Questions related to strings

Lexicographically first palindromic string

Rearrange the characters of the given string to form a lexicographically first palindromic string. If no such string exists display message “no palindromic string”. Examples: Input : malayalam Output : aalmymlaa Input : apple Output : no palindromic string Simple Approach: 1. Sort the string characters in alphabetical(ascending) order. 2. One be one find lexicographically… Read More »

Difference of two large numbers

Given two numbers as strings. The numbers may be very large (may not fit in long long int), the task is to find difference of these two numbers. Examples: Input : str1 = “11443333311111111100”, str2 = “1144422222221111” Output : 11442188888888889989 Input :str1 = “122387876566565674”, str2 = “31435454654554” Output : 122356441111911120 This is simple based on… Read More »

Maximum consecutive repeating character in string

Given a string, the task is to find maximum consecutive repeating character in string. Note : We do not need to consider overall count, but the count of repeating that appear at one place. Examples: Input : str = “geeekk” Output : e Input : str = “aaaabbcbbb” Output : a Asked in Amazon The… Read More »

Sum of two large numbers

Given two numbers as strings. The numbers may be very large (may not fit in long long int), the task is to find sum of these two numbers. Examples: Input : str1 = “3333311111111111”, str2 = “44422222221111” Output : 3377733333332222 Input : str1 = “7777555511111111”, str2 = “3332222221111” Output : 7780887733332222 The idea is based… Read More »

Group words with same set of characters

Given a list of words with lower cases. Implement a function to find all Words that have the same unique character set . Example: Input: words[] = { “may”, “student”, “students”, “dog”, “studentssess”, “god”, “cat”, “act”, “tab”, “bat”, “flow”, “wolf”, “lambs”, “amy”, “yam”, “balms”, “looped”, “poodle”}; Output : looped, poodle, lambs, balms, flow, wolf, tab,… Read More »