Interview Questions

Need to design a class for the following requirement.......

Microsoft Interview Questions and Answers


(Continued from previous question...)

115. Need to design a class for the following requirement.......

Question:
Need to design a class for the following requirement.
Input => hello world(html)
output => hello%dworld

input=>>>(xml)
output=><>

That mean if user pass any of the string , need to figure it encode string for each chracters and return the outut string.
These encoding character will change each application.
Once we complete encoding. Need to do decoding as well.


maybe an answer:


The 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.

(Continued on next question...)

Other Interview Questions