GeeksforGeeks

Add Interview/written questions to Interview Corner!!
Register  |  Login

Browsing the topic Strings

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 »

Asked by Jason.
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 backtracking.

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 [...]

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 keep track of [...]

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 value [...]

Read More »