GeeksforGeeks

A computer science portal for geeks
Register  |  Login

Browsing the topic Strings

Given three strings A, B and C. Write a function that checks whether C is an interleaving of A and B.

Read More »

Given two strings str1 and str2, write a function that prints all interleavings of the given two strings. You may assume that all characters in both strings are different

Read More »

Given a string, find the length of the longest substring without repeating characters. For example,

Read More »

Given two strings string1 and string2, find the smallest substring in string1 containing all characters of string2 efficiently.

Read More »

Given an input string, write a function that returns the Run Length Encoded string for the input string.

Read More »

Example: Let the input string be “i like this program very much”. The function should change the string to “much very program this like i”

Read More »

There is a list of items. Given a specific word, e.g., “sun”, print out all the items in list which contain all the characters of “sum”

Read More »

Algorithm: 1) Scan the string from left to right and construct the count array. 2) Again, scan the string from left to right and check for count of each character, if you find an element who’s count is 1, return it.

Read More »

Difficulty Level: Rookie Question: Write a program to print N equal parts of a given string.

Read More »

A permutation, also called an “arrangement number” or “order,” is a rearrangement of the elements of an ordered list S into a one-to-one correspondence with S itself. A string of length n has n! permutation. Source: Mathword(http://mathworld.wolfram.com/Permutation.html) Below are the permutations of string ABC. ABC, ACB, BAC, BCA, CAB, CBA Here is a solution using [...]

Read More »

Write a recursive C function to print reverse of a given string.

Read More »

Given a string s1 and a string s2, write a snippet to say whether s2 is a rotation of s1 using only one call to strstr routine? (eg given s1 = ABCD and s2 = CDAB, return true, given s1 = ABCD, and s2 = ACBD , return false) Algorithm: areRotations(str1, str2) 1. Create a [...]

Read More »

Write an efficient C function that takes two strings as arguments and removes the characters from first string which are present in second string (mask string). Algorithm: Let first input string be”test string” and the string which has characters to be removed from first string be “mask” 1: Initialize: res_ind = 0 /* index to [...]

Read More »

Algorithm: Let input string be “geeksforgeeks”
1: Construct character count array from the input string.

count['e'] = 4
count['g'] = 2
count['k'] = 2
……
2: Print all the indexes from the constructed array which have value greater than 0.

Read More »

Below are the different methods to remove duplicates in a string.

Read More »

Write an efficient C function to return maximum occurring character in the input string e.g., if input string is “test string” then function should return ‘t’. Algorithm: Input string = “test” 1: Construct character count array from the input string. count['e'] = 1 count['s'] = 1 count['t'] = 2 2: Return the index of maximum [...]

Read More »
Tweet