Microsoft Interview Question
Software Engineer / DevelopersThe easiest method for doing something like this is to use a native string.replace(" ", "%d") using a method that receives the character to be replaced and the type to replace it with to return [convert(" ", Type.HTML) returns "%d"]
A StringBuffer is another valid data structure to use, simply remove the found instance of the character to replace and then insert it's conversion
A character array would work for lower level languages but would require the overhead of having to manually shift characters down and resizing the array manually.
Why did you tag this a C#? Did the interviewer require you write this in C#?
- Anonymous March 17, 2011