String Manipulation Interview Questions
- 6of 6 votes
AnswersCode a function that receives a string composed by words separated by spaces and returns a string where words appear in the same order but than the original string, but every word is inverted.
Example, for this input string@"the boy ran"
the output would be
@"eht yob nar"
Tell the complexity of the solution.
- diegum June 06, 2014 in United States for iOS| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer String Manipulation - 3of 3 votes
AnswersCode a function that gets two strings representing binary numbers (so the only possible characters are '1' and '0', and returns a third string representing the sum of the input. The input strings don't necessarily have of the same length.
- diegum June 06, 2014 in United States for iOS
Tell the complexity of the solution.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer String Manipulation - 1of 1 vote
AnswersGiven three strings str1, str2 and str3; complete the function to find the smallest subsequence in str1 which contains all the characters in str2 (in any order) and not those in str3.
- ankur.emailid April 21, 2014 in India
Sample Test Case:
Sample Input:
str1: spqrstrupvqw
str2: sprt
str3: q
Sample Output: strup
Explanation: In the given string str1, the smallest subsequence that contains the characters in str2 ( 's' , 'p' , 'r' , 't' ) and does not contain the character in str3 ( 'q' ) is 'strup'.| Report Duplicate | Flag | PURGE
Morgan Stanley Java Developer String Manipulation - 19of 19 votes
AnswersGiven two strings a and b, find whether any anagram of string a is a sub-string of string b. For eg:
- Masterchief117 March 23, 2014 in United States
if a = xyz and b = afdgzyxksldfm then the program should return true.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer String Manipulation - 0of 0 votes
AnswersWrite a method which will accept a string and return true if the string is a palindrome and false if it isn't.
- Jeanclaude March 19, 2014 in United States
Special conditions:
a) your method should consider lower case and upper case characters to be the same.
b) your method should ignore special characters and white spaces, for e.g. if your input were the strings were "Madam, I'm Adam!!", then you should consider it a palindrome and hence return true ignoring case and special characters. Same with inputs like "Ma'am", "boB" etc should return true.| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer String Manipulation - 0of 0 votes
AnswersThere is a dictionary of billion words and there is one method provided
- pavan February 27, 2014 in India
String getWord(int index); We can give it index and it will return the String on that index .
Now word is given to us we have to find out its index. O(logn) solution was required.| Report Duplicate | Flag | PURGE
Amazon SDE1 String Manipulation - 0of 0 votes
AnswersImagine we have a large string like this "ABCBAHELLOHOWRACECARAREYOUIAMAIDOINGGOOD" which contains multiple palindromes within it, like ABCBA, RACECAR, ARA, IAMAI etc... Now write a method which will accept this large string and return the largest palindrome from this string. If there are two palindromes which are of same size, it would be sufficient to just return any one of them.
- Jeanclaude January 22, 2014 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test String Manipulation - 0of 0 votes
AnswersYou have a single string which contains all the positive numbers upto N concatenated together. If you are given an input number then how would you find the index position of the number in the string.
Eg:String str = "12345678910111213141516171819202122232425......upto 10000"; input = 20 should return the index of 20 in the string which is 29
The example string is upto 10000. The actual string can be upto any number N.
- anonymous January 06, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 String Manipulation - -2of 2 votes
AnswersGiven a class of block reader, read in unlimited string flow.
- chandeepsingh85 September 26, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer String Manipulation - 2of 2 votes
AnswersGiven a set top box:
- chandeepsingh85 September 26, 2013 in United States
a, b, c, d, e,
f, g, h, i, j,
k, l, m, n, o
p, q, r, s, t
u, v, w, x, y
z
Write code to give the character sequence given a word, For example, if the word is "CON", the function will print this:
Right//now we're at B
Right//now we're at C
OK//to select C
Down
DOwn
Right
Right
OK//to select O
Left//now at N
OK//to select N
note: Be careful when you're at Z. if you go to the right, you will get stuck.
Afterwards, the interviewer adds a space to the right of 'Z' to test the code.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Site Reliability Engineer String Manipulation Algorithm - 0of 0 votes
AnswersGiven a string with lower-case and Upper-case mixed, print all the permutation of it under the follow condition: the position of the upper-case letter can not be changed
- Muhammed September 25, 2013 in United States| Report Duplicate | Flag | PURGE
String Manipulation - 1of 1 vote
AnswersFind Whether a Input string had Palindrome?
- csenasa August 10, 2013 in India
Example :
Input Samples : "1234xyzyx5678" , "abcdefeabc"
Output : A Bool Value, True if Contains a Palindrome , False otherwise. ( In this Example input string conatins "xyzyx" and efe" Palindrome respectively)| Report Duplicate | Flag | PURGE
Intuit Senior Software Development Engineer Algorithm String Manipulation - -2of 2 votes
AnswersGiven a string T of length n, partition it in n' "phrases" (p1, p2, ..., pn'), such that
- hakkindumma June 21, 2013 in United States
pi = pj + c, for some j<i, where + is string concatenation and c is a character
p0 = ''
p1 = pj + c where j < 1
T = p1 + p2 + ... + pn'
For example:
T = aababcabcd = a + ab + abc + abcd
p1 p2 p3 p4| Report Duplicate | Flag | PURGE
Groupon Developer Program Engineer Algorithm Java String Manipulation - 0of 4 votes
AnswersWrite a function to search for the existence of a string (target) in another string (str). The function takes two strings as the input and returns the index where the second string is found. If the target string cannot be found, then return -1
- Rahul June 18, 2013 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer String Manipulation - 1of 1 vote
AnswersFind the first non repeating character in a given string. You may assume that the string contains any character from any language in the world, for e.g. an Arabic
- Jeanclaude June 09, 2013 in United States for Windows Phone
or Greek character even.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test String Manipulation - 4of 6 votes
AnswersGive you two sequences of length N, how to find the max window of matching
- Code2Win June 08, 2013 in India
patterns. The patterns can be mutated.
For example, seq1 = “ABCDEFG”, seq2 = “DBCAPFG”, then the max window is 4. (
ABCD from seq1 and DBCA from seq2).| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer String Manipulation - -5of 7 votes
Answersneed to implement a weather report functionality. user will provide the city name , need to return the weather report.
- gopi.komanduri May 29, 2013 in India
if weather station exists n functioning properly , will return the weather report of that station .
else ,
will return the nearest available weather station report.
interviewer looking for optimized manner.
looking for datastructures to stores the cities n algo to return the report.| Report Duplicate | Flag | PURGE
Mentor Graphics Analyst Algorithm Arrays Bit Manipulation Brain Teasers C C# C++ Cache Coding Computer Architecture & Low Level Data Mining Data Structures Dynamic Programming General Questions and Comments Graphics Hash Table Ideas Linked Lists Math & Computation Object Oriented Design Problem Solving Sets Sorting Stacks String Manipulation Terminology & Trivia Threads Trees and Graphs XML - 1of 1 vote
AnswersCode to check if a given short string is a substring of a main string. Can you get a linear solution (O(n)) if possible?
- Jeanclaude May 18, 2013 in United States for Office| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test String Manipulation - 1of 1 vote
AnswersGiven a string, find the longest possible even palindrome (length of palindrome is even) from it.
- arun_lisieux May 10, 2013 in India
Eg:
Input: abcicbbcdefggfed
Output: defggfed (length is 8)
Available palindromes are
1) bcicb - has odd length
2) cbbc - even length
3) defggfed - longest palindrome with even length
This question was asked in a telephonic interview for my friend. I will be posting his solution in a day.| Report Duplicate | Flag | PURGE
Groupon Software Engineer / Developer Algorithm Arrays Coding String Manipulation - 0of 0 votes
AnswersYou have a string str = "I love you".
- cCAACc May 04, 2013 in United States
Write a program to print the output as "you love I". Calculate the efficiency of your coding.| Report Duplicate | Flag | PURGE
Barclays Capital Senior Software Development Engineer String Manipulation - 1of 1 vote
AnswersYou are given a UNIX path with dot (current) and two dots (parent). Convert this to an absolute path
- JSDUDE April 30, 2013 in United States
E.g. $/home/abc/.././def/./ghi/../.
becomes $/home/ghi/| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test String Manipulation - 22of 22 votes
Answerswrite a function :
- SDguy April 20, 2013 in United States
char * CreateEmptyString(int len);
function should return an pointer to an empty string of length len| Report Duplicate | Flag | PURGE
Apple Quality Assurance Engineer String Manipulation - 2of 2 votes
AnswersYou have a very very big text file.How would you read & process it to print the below output.
- cCAACc April 20, 2013 in United States
1. Print the top ten ranked distinct words.
2. Print the occurrence of the each alphabet in this file.
For example:
ABC (100)
XYZ (40)
PQR (10)
THE (200)
IN (200)
Then I have to display the output as
IN (200)
THE (200)
ABC (100)
XYZ (40).
And
A=1000
B=2000
C= 300
.. ...
z=300| Report Duplicate | Flag | PURGE
Citigroup Financial Software Developer String Manipulation - -1of 1 vote
AnswersA string of characters were given, find the highest occurrence of the character and display it.
- nivi.keshri1111 March 26, 2013 in United States
input:AJDHURNANDANDJNAUYTRAYAUIA
output: A| Report Duplicate | Flag | PURGE
String Manipulation - 11of 11 votes
AnswersGiven a string, find whether it has any permutation of another string. For example, given "abcdefg" and "ba", it shuold return true, because "abcdefg" has substring "ab", which is a permutation of "ba".
- sg March 02, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test String Manipulation - 0of 0 votes
AnswersGive an algorithm which removes the occurrence of A and I from string ? The algorithm must be in-place.
- Ashish January 31, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer String Manipulation - 1of 1 vote
AnswersGiven a string, find the start position of the largest block of repeated charactes.
- hnrqbaggio January 24, 2013 in United States for Office
After the solution, I was asked to write down as many test cases I could to test the function as if it was created by someone else.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm Microsoft String Manipulation Testing - 0of 0 votes
AnswersYou are given two Strings lets say "S" which consist Upper Case albhabets and '?' character only and p. You are required to replace '?' with some alphabet so that resulting string have maximum number of "p" in it. You can replace '?' with any alphabet.
2. Replace '?' such that it should be lexicographically sorted.
Example
S="ABAAMA????MAZON????????"
p="AMAZON"
The final string S = "ABAAMAZONAMAZONAAAMAZON"
S="?????"
p="ABCD"
Final Result="AABCD"
Soln:- Proceed from the end of the String.
- Shashi January 22, 2013 in United States#include<stdlib.h> #include<stdio.h> #include<string.h> int main() { char S[]="ABAAMA????MAZON????????"; char p[]="AMAZON"; printf("%s \n",S); int i,j,flag=0; i=i=strlen(S)-1; while(i>=0) { int k=i; for(j=strlen(p)-1;j>=0;j--) { if(S[k]==p[j] || S[k]=='?') { k--; flag=1; } else { flag=0; break; } } int m=i if(flag==1) { for(j=strlen(p)-1;j>=0;j--) { if(S[m]=='?') S[m]=p[j]; m--; } } else { if(S[i]=='?') S[i]='A'; } i--; } printf("%s",S); }
| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer String Manipulation