views:

624

answers:

8

Hi,
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

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

+7  A: 

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

qaxi
I agree about the importance of regular expressions for string manipulation.
Mr Roys
if they use low-level string manipulations they would never use regex
01
+1  A: 

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.

unwind
A: 

Check this out. Might not fit the description for 'classic', but very interesting.

Zaki
A: 

The list of possible questions (problems) is endless.

Just learn the features provided by java.lang.String, and perhaps StringUtils from commons-lang and you will be able to solve them all.

Bozho
A: 

I'd look up string algorithms in a good algorithm book. For example, the Boyer-Moore algorithm, Tries, Suffix Trees, Minimum Edit Distance, stuff like that.

nikie
A: 

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.

drawnonward
+1  A: 

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.

grokus
I should have said that you can do this in-place.
grokus
hey thanks for this question
Remember position of the last space char, then shift last word to the left, so that this word will be the first one. Do it for every word.
psihodelia
A: 

Design a regular expression library.

Ken