Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Classic string manipulation interview questions? [closed]

Tags:

string

I am scheduled to have an onsite interview so I am preparing few basic questions. According to the company profile, they are big on string manipulation questions. So far I have manually coded these functions:

  1. String length, copy, concat, remove white space
  2. Reverse
  3. Anagrams
  4. Palindrome

Can someone give me a list of more classic string questions which I can practice before going there?

like image 713
Ray Avatar asked Apr 14 '10 06:04

Ray


4 Answers

They might ask you about regular expressions. If they are using Java, they might ask the difference of StringBuffer and StringBuilder.

like image 152
qaxi Avatar answered Nov 06 '22 00:11

qaxi


Reverse words in a sentence, e.g.

"string manip interview question"

becomes

"question interview manip string"

this has a solution that uses only one char worth of temporary space.

like image 35
grokus Avatar answered Nov 05 '22 23:11

grokus


Make sure your reversal is in-place. You didn't state, so perhaps it already is.

Asking you to re-implementing strstr() or strtok() might be up their alley too, I guess.

UPDATE: As a bonus, if you do end up re-implementing either of those, remember to not name your functions starting with str, since that namespace is reserved. Having a candidate display that knowledge in an interview would impress me, at least. :)

like image 3
unwind Avatar answered Nov 06 '22 00:11

unwind


Fast search like Boyer-Moore and Knuth-Morris-Pratt. Fast strlen by examining more than one byte at a time. Simultaneously finding multiple strings in a large body of text with Rabin-Karp. Finding nearest matches with things like Levenshtein distance. Regular expressions and how they might implement parts of it. Various unicode and other multibyte string encodings and how to convert between them.

like image 2
drawnonward Avatar answered Nov 05 '22 23:11

drawnonward