Bloomberg LP Interview Question for Financial Software Developers






Comment hidden because of low score. Click to expand.
1
of 0 vote

void spacing(char* str)
{
int read, write;
read = write = 0;

while(str[read])
{
//copy till a white space has been found
while(str[read] != ' ' && str[read])
{
str[write++] = str[read++];
}

//on a whitespace
if(str[read] == ' ')
{
str[write++] = str[read++];
}

//keep incrementing read till no more white spaces are found
while(str[read] == ' ' && str[read])
{
read++;
}

}
//Null terminate
str[write] = '\0';
}

- Sush November 27, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

char * removeExtra(char *str)
{
if(str==null)
return str;
int space=0,writePtr=0,i=0;
while(str[i]!='\0')
{
if(str[i]=='\0')
{
space++;
}
else
space=0;

if(space<=1)
{
str[w]=str[i];
w++;
}
i++;
}
str[w]='\0';
}

- worthless October 28, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <iostream>

char *rpl_mult_spaces(char *input);

int main()
{
char *result=rpl_mult_spaces("aaa bb c d");
printf("%s",result);
return 0;
}

char *rpl_mult_spaces(char *input)
{
int len=strlen(input);
char *p=input;
char* dest=new char[len];
memset(dest,'\0',len);
char *q=dest;

int i=0;
while(i<len)
{
if(*p!=' ')
{
*q=*p;
p++;
q++;
i++;
}
else
{
while(*p==' ')
{
p++;
i++;
}
*q=' ';
q++;
}
}
return dest;
}

- smartlhc October 30, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <stdio.h>
#include <stdlib.h>

int main(void){

char a[100] ;
int i , j ;
i = j = 0 ;
printf("Enter the string\n") ;
fgets(a,sizeof(a),stdin);
a[strlen(a) -1 ] = '\0' ;
while(a[i] != '\0'){

while(a[i] != ' ' && a[i] != '\0'){
a[j]=a[i] ;
i++ ;j++;
}
a[j]=a[i] ;j++ ;
while(a[i] == ' ' && a[i] != '\0') i++ ;
}

printf("New string:%s\n",a) ;
}

- bcat November 17, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void replaceExtraSpace(char* str){
int i = 1;
int j = 0;
if(strlen(str) == 0) return;
while(str[i] != '\0'){
if(str[i] != ' ' || str[j]!= ' ')
str[++j] = str[i];
++i;
}
str[++j] = '\0';
}

- fakong December 06, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int i=0,j=0;
int n = strlen(str);

while(i<n){
if(a[j]!=a[i]){
j++;
a[j]=a[i];
}
i++;
}
a[j+1]='\0';

- webchic April 07, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void remove_extra_space(char* str){
  char *removedPtr = str;
  while(*str){
    if(*str == ' ')
      *removedPtr++ = *str++;
    while(*str == ' ')
      ++str;
    *removedPtr++ = *str++;
  }
  *removedPtr = '\0';
}

btw: if you guys could put the code inside

, it makes reading much easier

- roger September 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes
i mean put the code inside {{{{{{}}}}}} - roger September 11, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

inside three braces

- Anonymous September 11, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Courtesy of Python:

def remove_mult_spaces(s):
    return ''.join(w + ' ' for w in s.split() if w is not '').rstrip()

- Bullocks December 29, 2009 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More