Pergunta de entrevista da empresa Libsys (Illinois)

Write a program which removes all blank spaces from a given string. The complexity of the code, should be less than O(n*n).

Resposta da entrevista

Sigiloso

19 de set. de 2015

Here is an O(n) implementation. It's will show warning for using deprecated method gets() but it will run correctly. #include int main() { char ch[100],res[100]; int i; gets(ch); i=0; int j=0,flag=1; while(ch[i]!='\0') { if(ch[i]!=' ') res[j++]=ch[i++]; else i++; } res[j]='\0'; printf("%s",res); return 0; }