mrinalkamboj
BAN USER- 0of 0 votes
AnswersFor a string with uneven number of white spaces, what is best method or algorithm to trim the white spaces between characters, except special characters like !or,
- mrinalkamboj in India for Bing
Also the beginning and end should not contain any white space| Report Duplicate | Flag | PURGE
Microsoft Tech Lead Algorithm - 2of 2 votes
AnswersGiven a 2D array of size m X n, containing either 1 or 0. As we traverse through, where ever we encounter 0, we need to convert the whole corresponding row and column to 0, where the original value may or may not be 0. Now devise an algorithm to solve the problem minimizing the time and space complexity.
- mrinalkamboj in India for Bing| Report Duplicate | Flag | PURGE
Microsoft Tech Lead Algorithm
You cannot use APIs, implement the working of Replace
- mrinalkamboj January 02, 2013You cannot use APIs, you need to implement the working of Trim and Replace APIs
- mrinalkamboj January 02, 2013Try it out this solution, it will not work, since you need to do it in the same buffer, when you copy characters to whitespace, then you need to convert the index of the characters being copied to whitespace, else it would lead to doubling of characters.
Also, the access part pointed earlier is also an issue
You need to implement Trim() :)
- mrinalkamboj January 02, 2013Yes, I missed out that important point we need to do it in a single buffer, no extra buffer should be allocated
- mrinalkamboj January 02, 2013
Repmarthavmoody, Consultant at Dell
Spent 2002-2010 investing in toy elephants in Pensacola, FL. Earned praised for my work testing the market for squirt guns ...
Operation of trimming the whitespace has to be done in a single buffer, we cannot use multiple buffers, I missed out this point in the question
- mrinalkamboj January 02, 2013