Labels

Friday, August 12, 2011

Paragraph edit

problem statement : given a paragraph string, remove the extra spaces
for example = " welcome       to      linux ! "
output = "welcome to linux !"

concept : traverse the string and set flag when one space is encountered , skip the input till next non space character is found, reset the flag..
quite simple but useful program



time complexity O(n)

No comments:

Post a Comment