String Interview Questions | Glassdoor

String Interview Questions

23

interview questions shared by candidates

String Interview Questions

Sort: Relevance Popular Date

Given a string, remove all the duplicate characters (not necessarily consecutive)

9 Answers

void removeDuplicates(char *in, char *out) { bool seen[NUM_CHARS] = {false}; while (*p != 0) { if (seen[*p] == 0) { *out++ = *p; } seen[*p] = true; } }

public class StringRemove { private final String baseString = "abcdefghijklmnopqrstuvwxyz12345678910"; private final List finalMap = new ArrayList(); private StringBuffer sb = new StringBuffer(); private void findDup(){ for(int i=1 ; i <= baseString.length() ; i++) { String sLocal = baseString.substring(i-1, i); if(finalMap.contains(sLocal)){ finalMap.remove(sLocal); }else{ finalMap.add(sLocal); } } String s = finalMap.toString(); s = s.replace('[',' ').replace(']',' ').replace(',', ' ').replace(',', ' ').trim().replaceAll(" ", ""); System.out.println(s); } public static void main(String s[]){ StringRemove sr = new StringRemove(); sr.findDup(); }

void RemoveDuplicates(char[] arr, int length) { Map charMap = new Map(); int currenPosition = 0; for (int i=0;i<length;i++) { bool exists = charMap[char[i]]; if (!exists) { arr[currentPosition] = arr[i]; currentPosition++; } charMap[char[i]] = true; } // terminate the string arr[currentPosition] = '\0'; }

Given a string find the first non-repeated character.

10 Answers

Given a string like "I'm being interviewed by Amazon" implement a method that reverses the given string so that it looks like "Amazon by interviewed being I'm".

8 Answers

Given an array, put all repeated characters together.

4 Answers

convert the result of 7^n (7 to the Nth) to string

3 Answers

Write a program takes in a string and a delimiter, and uses that delimiter to split a string and then will reverse the characters in every word (or jumble of characters between the delimiters), stuffing them back into a string when finished. ('The dog walks' becomes..... 'ehT god sklaw')

4 Answers

Given a series of strings, find the biggest common prefix.

4 Answers

Given a set of Sentences containing lower case letters only, remove common phrases from each sentence. Here a phrase is defined by 3 or more consecutive words. E.g: S1 = "I my bye good"; S2 = "my bye good boy"; common phrase is: "my bye good" so the two sentence become S1 = "I"; s2 ="boy";

3 Answers

Given a trie and a prefix, find the word (in the trie) that starts with some subsequence of the prefix and also has the longest such subsequence.

2 Answers

Find substring 'substr' in string 'str'

2 Answers
110 of 23 Interview Questions