String Manipulation Interview Questions
- 0of 0 votes
AnswersGiven a DNA sequence e.g. AAAGTAAGTAAGTGGG.....
- rajnikant12345 March 13, 2016 in India for Office
Find all the duplicates with length 10.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 String Manipulation - 1of 1 vote
AnswersWrite 2 functions to serialize and deserialize an array of strings. strings can contain any unicode character. Do not worry about string overflow.
- TheShocker1999 December 08, 2015 in United States| Report Duplicate | Flag | PURGE
Google Developer Program Engineer String Manipulation - 0of 0 votes
AnswersFind if the characters of the sample string is in the same order in the text string.. Give a simple algo..
- sachin.and3 October 18, 2015 in United States
Eg.. TextString: abcNjhgAhGjhfhAljhRkhgRbhjbevfhO
Sample string :NAGARRO| Report Duplicate | Flag | PURGE
Nagarro Java Developer Algorithm Arrays Brain Storming Brain Teasers Coding Hash Table String Manipulation - 0of 0 votes
AnswersSplit the string
- a267512 October 09, 2015 in United States
example:
String: programmingproblem
Pattern: 6 5 7
separator: ;
Result: progra;mming;problem
exception if the string has less or more characters given in the pattern.
the program will take three inputs from the user, first string, second pattern and third pattern separator| Report Duplicate | Flag | PURGE
String Manipulation - 0of 0 votes
AnswersGiven a string and array of strings, find whether the array contains a string with one character difference from the given string. Array may contain string of different lengths.
Ex: Given stringbanana
and array is
[bana, apple, banaba, bonanza, banamf]
and the outpost should be true as banana and banaba are one character difference.
- kpraveen420 October 03, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Arrays String Manipulation - 2of 2 votes
AnswersA multiset or a bag is a collection of elements that can be repeated. Contrast with a set, where elements cannot be repeated.
- ersegun August 20, 2015 in Netherlands
Multisets can be intersected just like sets can be intersected.
Input :
A = [0,1,1,2,2,5]
B = [0,1,2,2,2,6]
Output :
A ∩ B = C = [0,1,2,2]
Input :
A = [0,1,1]
B = [0,1,2,3,4,5,6]
Output
A ∩ B = C = [0,1]
Write a function to find the intersection of two integer arrays in that way ?| Report Duplicate | Flag | PURGE
Booking.com Software Developer String Manipulation - 2of 2 votes
Answers"Smart substring"
- ersegun August 20, 2015 in Netherlands
Write a function that takes maximum 30 characters from a string but without cutting the words.
Full description:
"Featuring stylish rooms and moorings for recreation boats, Room Mate Aitana is a designer hotel built in 2013 on an island in the IJ River in Amsterdam."
First 30 characters:
"Featuring stylish rooms and mo"
Smarter approach (max 30 characters, no words are broken):
"Featuring stylish rooms and"| Report Duplicate | Flag | PURGE
Booking.com Software Developer String Manipulation - 0of 0 votes
AnswersGiven an array of integers you to find the range l,r such that and operation of largest two element in that range is maximum.
- ritwik_pandey August 09, 2015 in India
For example:
Input
6 1 6
Output
1 3
You have to print lexicographically smallest range.| Report Duplicate | Flag | PURGE
SumoLogic SDE-3 String Manipulation - 0of 0 votes
AnswersInput: two strings, one is short then the other
- dana August 03, 2015 in Israel for Application insight
Output: indices of where a permutation of the short string start at the long string.| Report Duplicate | Flag | PURGE
Microsoft String Manipulation - 2of 2 votes
AnswersWrite program for the following case
- APV July 25, 2015 in India for Amazon Wireless
Reverse string (string is stored in an array)
Input:- "This is an example"
Output:-sihT si na elpmaxe| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer String Manipulation - 0of 0 votes
AnswersWrite an itoa
- JSDUDE July 09, 2015 in United States| Report Duplicate | Flag | PURGE
Booking.com Software Developer Algorithm String Manipulation - 1of 1 vote
AnswersGiven a start string, end string and a set of strings, find if there exists a path between the start string and end string via the set of strings.
- JSDUDE June 23, 2015 in United States for Customer experience
A path exists if we can get from start string to end string by changing (no addition/removal) only one character at a time. The restriction is that the new string generated after changing one character has to be in the set.
start: "cog"
end: "bad"
set: ["bag", "cag", "cat", "fag", "con", "rat", "sat", "fog"]
one of the paths: "cog" -> "fog" -> "fag" -> "bag" -> "bad"| Report Duplicate | Flag | PURGE
Walmart Labs Software Developer Algorithm String Manipulation - -1of 1 vote
Answers
- JSDUDE June 04, 2015 in United Statespublic class StringUtilities { /** * Count the maximum depth of parenthesis nesting, i.e. "abc(123(xyz))m(((n)))o" -> 3. * * @param input * any string * @return deepest parenthesization level * @throws IllegalArgumentException * if input is null or contains a mismatch "a)b(c" or "a(b" */ public static int nestedParenthesisDepth(String input) throws IllegalArgumentException { //... } }
| Report Duplicate | Flag | PURGE
Walmart Labs Software Engineer Algorithm String Manipulation - 1of 1 vote
AnswersGiven a string left rotate it by given number of times with O(n) solution
- pc June 02, 2015 in India| Report Duplicate | Flag | PURGE
Microsoft Senior Software Development Engineer Algorithm String Manipulation - 1of 3 votes
AnswersWe know a string is Palindrome if it is the same reading from both sides. Now we define the following string also Palindrome:
- amirtar May 05, 2015 in United States
A man, a plan, a canal, Panama!
Write a code that returns if an string is palindrome and it should return true for above input. (Without directly saying, I should conclude that I have to only consider alphanumerical characters in a string). In addition, we assume the string is very long and we can not keep a copy of this string or even a copy of preprocessed version of this string. Therefore the result should be returned with the first sweep of the string.| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm String Manipulation - 0of 0 votes
AnswersIn my First round, very first question that guy asked me is to generate an algorithm to check whether string is palindrome or not. After that in the same round, he asked me to create a class that duplicates the Stack property.
First, String Palindrome:
Used stringbuilder, i.e.StringBuilder sb = new StringBuilder(str); System.out.println(sb.reverse());
then he told me to not to use StringBuilder, so i convert string into the char array, then apply loop till half the size of the string. and check character by character. He said ok. "looks good".
- darpanshah08 March 24, 2015 in United States for Amazon Prime| Report Duplicate | Flag | PURGE
US Software Engineer Stacks String Manipulation - 1of 1 vote
AnswersYou are tasked with implementing a method that returns the lowest possible number that could be generated after removing n characters from a string of digits. The method signature should look like:
public static string GenerateLowestNumber(string number, int n)
Where the number parameter is a string that contains a number (e.g. “4205123”), and the n parameter represents the number of characters to remove from the string. The goal of this method is to return the lowest number that can be generated by removing n characters from the number provided while keeping the positions of the remaining characters relative to each other the same (i.e. the method should remove n characters from the string, but it cannot re-order the characters).
- JSDUDE March 14, 2015 in United States for Cloud + Enterprise
For example, if number is “4205123” and n is 4, the lowest possible number that can be generated after removing any 4 characters is “012”. If number is “216504” and n is 3, the lowest possible number that can be generated after removing 3 characters is “104”.| Report Duplicate | Flag | PURGE
Microsoft Software Developer Algorithm String Manipulation - 0of 0 votes
AnswersPlay Scrabble. You have 7 letters to start from. Build the word with the highest score.
- marinalepi March 06, 2015 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer String Manipulation - 0of 0 votes
AnswersWrite code that would parse an expression that is similar to BASH brace expansion. Best illustrated with an example: the expression "(a,b,cy)n,m" would be parsed into an array of the following strings:
- demonix February 12, 2015
an
bn
cyn
m
You can assume that the input will always be valid.
Hint: the expression can nest. Therefore, "((a,b)o(m,n)p,b)" parses into:
aomp
aonp
bomp
bonp
b| Report Duplicate | Flag | PURGE
Google Software Engineer Intern String Manipulation - 1of 3 votes
Answersdesign and implement a calculater that can calculate expressions like:
- srcnaks February 02, 2015 in -
+ 2 4
* 8 ( + 7 12)
( + 7 ( * 8 12 ) ( * 2 (+ 9 4) 7 ) 3 )
(PS:all items are space delimetered.)
Example answers
+ 2 4 => 2 + 4 = 6
* 8 ( + 7 12) => 8 * ( 7 + 12 ) = 152
( + 7 ( * 8 12 ) ( * 2 (+ 9 4) 7 ) 3 ) => 7+8*12+2*(9+4)*7+3 = 148| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Data Structures Problem Solving Stacks String Manipulation Trees and Graphs - 0of 0 votes
AnswersGiven a string write a function to return the length of the longest sub string with only unique characters
- JSDUDE January 21, 2015 in United States| Report Duplicate | Flag | PURGE
Clean Power Research Software Engineer / Developer String Manipulation - 3of 3 votes
AnswersThis question was asked in the chat, just adding here with the solution. I don't know for which company it is.
Replace wild cards with all possible combinations of zeros and ones using recursion.Input String: 0?1? Output: 0010, 0011, 0110, 0111
This is my solution using recursion:
- gigi84 December 20, 2014import java.util.*; public class ReplaceWildcardsRec { public static List<String> expandString(String s, int i) { List<String> l = new ArrayList<String>(); if(i>s.length()-1) { l.add(""); return l; } for(String expanded: expandString(s,i+1)) { if(s.charAt(i)=='?') { l.add('0'+expanded); l.add('1'+expanded); } else { l.add(s.charAt(i)+expanded); } } return l; } public static void main(String[] args) { List<String> l = new ArrayList<String>(); String s = "1111?"; l = expandString(s,0); System.out.println(l); } }
| Report Duplicate | Flag | PURGE
String Manipulation - 9of 9 votes
AnswersGiven a string (1-d array) , find if there is any sub-sequence that repeats itself.
- for.anonymous.usa October 22, 2014 in United States
Here, sub-sequence can be a non-contiguous pattern, with the same relative order.
Eg:
1. abab <------yes, ab is repeated
2. abba <---- No, a and b follow different order
3. acbdaghfb <-------- yes there is a followed by b at two places
4. abcdacb <----- yes a followed by b twice
The above should be applicable to ANY TWO (or every two) characters in the string and optimum over time.
In the sense, it should be checked for every pair of characters in the string.| Report Duplicate | Flag | PURGE
Google Software Engineer Intern Algorithm Brain Teasers C C++ Coding Data Structures Dynamic Programming Problem Solving String Manipulation - 0of 0 votes
AnswersGiven a string and a regular expression pattern, give the number of times the pattern occurs in the string. RegEx example means as follows:
- zeal October 20, 2014 in India
. – 2 occurrences of the previous character
+ – 4 occurrences of the previous character
* – more than 5 occurrences of the previous character
Sample Input:
5
aaaaaannndnnnnnnfffhfhhgjjjwkkkllclc
a.
n+
a*
an.
a.d.
Sample Output:
5
3
2
1
0| Report Duplicate | Flag | PURGE
BrowserStack SDE1 String Manipulation - 1of 1 vote
AnswersReplace %20 with ' '.
- Lawjick October 16, 2014 in United States
E.g. input: www.space%20.com
output: www.space .com| Report Duplicate | Flag | PURGE
Amazon SDET String Manipulation - 0of 0 votes
AnswersSay you have a string:
- LCHammer September 25, 2014 in United States for Advertising
"Thisisasentence"
How would you separate the string into separate words, return either the sentence with spaces or as a list/array where each entry is a word| Report Duplicate | Flag | PURGE
Amazon SDE1 String Manipulation - 12of 12 votes
AnswersGiven a mapping of alphabets to integers as follows:
- skrish August 13, 2014 in United States
1 = A
2 = B
3 = C
...
26 = Z
Given any combination of the mapping numbers as string, return the number of ways in which the input string can be split into sub-strings and represented as character strings. For e.g. given
"111" -> "AAA", "AK", "KA" -> 3
Valid combinations are ({1,1,1}, {1,11},{11,1}) = 3
"11" -> "AA", "K" -> 2
Valid combinations are ({1,1},{11}) = 2
"123" -> "ABC", "LC", "AW" -> 3
Valid combinations are ({1,2,3},{1,23},{12,3}) = 3
You don't have to return all the mappings, only the number of valid mappings.| Report Duplicate | Flag | PURGE
Facebook Senior Software Development Engineer String Manipulation - 1of 3 votes
Answersreplace all occurrence of particular word with another word of larger length. Solution should be inplace can do copy only one time.
- anonymous June 30, 2014 in India
e.g.
Gandhi was born in 1969. Gandhi was from gujrat.
replace gandhi with mahatma| Report Duplicate | Flag | PURGE
String Manipulation - 4of 4 votes
AnswersYou are given a string S and a set of n substrings. You are supposed to remove every instance of those n substrings from S so that S is of the minimum length and output this minimum length.
- pnkapadia6 June 08, 2014 in India
Eg:
S- ccdaabcdbb
n=2 - substrings-- ab, cd
Output: 2
Explanation:
ccdaabcdbb -> ccdacdbb -> cabb -> cb (length=2)
Can someone help me with the algo?| Report Duplicate | Flag | PURGE
Hackerrank Software Engineer Intern String Manipulation