Lilou Laure wrote:This should be done without using any String functions like indexOf(), substring(), etc. Only charAt() can be used.
Lilou Laure wrote:How to do it ?
Lilou Laure wrote:And why do they not allow these functions to be used ? Then what is the point of learning these advanced features and doing Java certifications adn learning Java in depth?
O Shea wrote:I have done this question quite a bit, but what I am not getting is that in the final String how to remove the string "I want to". I have removed it, but I am getting boxes in place of the blank.
Here is my approach.
Please guide me how to get rid of those boxes and get only single space. Basically I have performed subtraction but, don't know how to avoid those boxes and get only single space.
Please correct me wherever I am wrong, since I followed very naive approach
Also, what I am getting is->
Space complexity-> O(n)
Time Complexity-> O(n^2) // little big
Please guide me how to improve the above approach to get less time complexity as compared to O(n^2).
Thanks Lilou, for such a great question.
Well, can you tell me that in which company's interview, this question was asked?
Jeanne wrote:They are trying to test your understanding of loops and your logic. They wouldn't have you do this once they hired you. It's hard to come up with interview questions that are simple enough to code at an interview and non trivial. So sometimes that comes with adding constraints such as this one.